C编程调试出现问题

xiniu999 2007-04-06 11:38:02
#include<stdio.h>
#include<malloc.h>
struct stu
{int num;
struct stu * next;
};

void main()
{int len=1,i;
struct stu *p1,*p2,*head,* new1,*new1head;
p1=p2=head=(struct stu *) malloc(sizeof(struct stu));
printf("input number(0:list end):");
scanf("%d",&p1->num);
while(p1->num!=0)
{p1=(struct stu *)malloc(sizeof(struct stu));
printf("input number(0:list end):");
scanf("%d",&p1->num);
if(p1->num==0)
p2->next=NULL;
else
{p2->next=p1;
p2=p1;
len++;
}
}
p1=head;
printf("\noriginal list:\n");
do
{printf("%4d",p1->num);
if(p1->next!=NULL)
p1=p1->next;
}while(p1->next!=NULL);
printf("%4d",p1->num);

for(i=0;i<len;i++)
{p2=p1=head;
while(p1->next!=NULL)
{p2=p1;
p1=p1->next;
}
if(i==0)
new1head=new1=p1;
else
new1=new1->next=p1;
p2->next=NULL;
}
printf("\n\nnew list:\n");
p1=new1head;
for(i=0;i<len;i++)
{printf("%4d",p1->num);
p1=p1->next;
}
printf("\n")
}

出错提示:E:\C语言上机调试\1112.cpp(54) : error C2143: syntax error : missing ';' before '}'
Error executing cl.exe.

1112.obj - 1 error(s), 0 warning(s)

...全文
201 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jjjkl81 2007-04-06
  • 打赏
  • 举报
回复
error C2143: syntax error : missing ';' before '}'
--------
请看出错提示,谢谢
bargio_susie 2007-04-06
  • 打赏
  • 举报
回复
1112.cpp(54) : error C2143: syntax error : missing ';' before '}'

提示都这明显了,你在错误提示上双击下不就知道是在哪个地方了。。。
iu_81 2007-04-06
  • 打赏
  • 举报
回复
最后的printf("\n")后面加上分号

33,321

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧