鱼C论坛

 找回密码
 立即注册
查看: 3479|回复: 0

c语言链表在不同编译器下的问题

[复制链接]
发表于 2012-9-27 23:19:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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) ===|

虽然不是什么大问题,但若有人知晓的还望多多指教一下~
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-15 07:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表