余罪里的歌曲:一道c语言,急用

来源:百度文库 编辑:高校问答 时间:2024/05/05 09:33:43
以下程序段的功能是统计链表中的结点的个数,其中first为指向第一个结点的指针(链表不带头结点),请填空
struct link
{ char data;
struct link *next;
};
...
struct link *p,*firs;
int c=0;
p=first;
while( )
{ ;
p= ;}
这个程序在我的机子上运行有错误,怎么样修改呢?

struct link
{ char data;
struct link *next;
};
...
struct link *p,*firs;
int c=0;
p=first;
while(p!=NULL)
{
c++;
p=p->next;
}

while(p!=NULL)
{ c++;
p=p->next ;}