#include
#include
struct stu{
int num;
char name[20];
struct stu *next;
};
void main()
{
FILE *fp;
struct stu *head,**p1,*p2;
int i=0,n;
char b;
printf("请输入学生总数!\n");
scanf("%d",&n);
p1=&head;
start:
*p1=(struct stu*)malloc(sizeof(struct stu));
printf("请输入序号,姓名:\n");
scanf("%d,%s",&(*p1)->num,(*p1)->name);
if(!i)
{head=*p1;p1=&(head->next);}
else {p1=&(*p1)->next;}
i++;
if(i
fp=fopen("xyj.txt","w");
if(fp==NULL)
{
printf("file write failed!\n");
goto end;
}
printf("Will you add the formation\n to the file of \"xyj.txt\"?[Y/N]\n");
scanf("\n%c",&b);
if(b=='y'||b=='Y')
for(i=0;i
fwrite(p2,sizeof(struct stu),1,fp);
p2=p2->next;
}
else
printf("Thanks for using!\n");
end:fclose(fp);
}
修改它干什么?
不能用吗?