首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C编程调试出现有关问题

2012-03-21 
C编程调试出现问题#include stdio.h#include malloc.hstructstu{intnumstructstu*next}voidmain(){

C编程调试出现问题
#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)



[解决办法]
最后的printf( "\n ")后面加上分号

热点排行