|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
先贴代码
#include <stdio.h>
#include <stdlib.h>
struct pNode
{
int data;
struct pNode *pNext;
};
int main()
{
int i;
struct pNode *pHead=(struct pNode *)malloc(sizeof(struct pNode));
struct pNode *pTail=pHead;
//pTail=pHead;
pTail->pNext=NULL;
for(i=0;i<4;i++)
{
struct pNode *pNew=(struct pNode *)malloc(sizeof(struct pNode));
pNew->data=i;
pNew->pNext=NULL;
pTail->pNext=pNew;
pTail=pNew;
}
struct pNode *p=NULL;
p=pHead->pNext;
while(NULL!=p)
{
printf("%d\n",p->data);
p=p->pNext;
}
return 0;
}
这段代码在VC++6.0下成功编译并得出了正确结果
但在Code::Blacks VC2010编译环境下却出现了很多错误
||=== scs, Debug ===|
main.c|23|error C2143: syntax error : missing ';' before 'type'|
main.c|24|error C2065: 'p' : undeclared identifier|
main.c|24|warning C4047: '=' : 'int' differs in levels of indirection from 'pNode *'|
main.c|25|error C2065: 'p' : undeclared identifier|
main.c|25|warning C4047: '!=' : 'void *' differs in levels of indirection from 'int'|
main.c|27|error C2065: 'p' : undeclared identifier|
main.c|27|error C2223: left of '->data' must point to struct/union|
main.c|28|error C2065: 'p' : undeclared identifier|
main.c|28|error C2065: 'p' : undeclared identifier|
main.c|28|error C2223: left of '->pNext' must point to struct/union|
||=== Build finished: 8 errors, 2 warnings (0 minutes, 0 seconds) ===|
虽然不是什么大问题,但若有人知晓的还望多多指教一下~
|
|