C语言实现学籍管理系统.docVIP

  • 2
  • 0
  • 约1.09万字
  • 约 14页
  • 2016-09-21 发布于重庆
  • 举报
C语言实现学籍管理系统

#includestdio.h #includestdlib.h #includestring.h #define len (sizeof(struct st)) #define LEN (sizeof(struct stu)) struct st { __int64 num; char name[20]; char sex; }; struct stu { struct st student; struct stu *next; }; struct stu *creatlist() { printf(输入零结束\n); struct stu *h,*p,*q; int n=0; h=NULL; q=p=(struct stu *)malloc(LEN); printf(请输入学生学号\n); scanf(%I64d,q-student.num); if(q-student.num!=0) { printf(请输入学生名字\n); scanf(%s,q-); printf(请输入学生的性别\n); scanf( %c,q-student.sex); while(1) { n=n+1; if(n==1) h=p; else { p-next=q; p=q; } q=(struct stu *)malloc(len); printf(请输入学生学号\n); scanf(%I64d,q-student.num); if(q-student.num==0) { free(q); break; } printf(请输入名字\n); scanf(%s,q-); printf(请输入学生的性别\n); scanf( %c,q-student.sex); } } p-next=NULL; printf(一共有%d节点\n,n); return h; } void save1(struct stu *head) { struct stu *p; p=head; FILE *fp; if((fp=fopen(www.txt,a))==NULL) { printf(con not open this file\n); exit(0); } while(p!=NULL) { fwrite(p-student,len,1,fp); p=p-next; } fclose(fp); printf(保存成功\n); } void save2(struct stu *head) { struct stu *p; p=head; FILE *fp; if((fp=fopen(www.txt,w+))==NULL) { printf(con not open this file\n); exit(0); } while(p!=NULL) { fwrite(p-student,len,1,fp); p=p-next; } printf(保存成功\n); fclose(fp); } void save3(struct stu *head) { struct stu *p; p=head; FILE *fp; if((fp=fopen(recycle.txt,w+))==NULL) { printf(con not open this file\n); exit(0); } while(p!=NULL) { fwrite(p-student,len,1,fp); p=p-next; } printf(保存成功\n); fclose(fp); } struct stu *display() { int n=0,i,j; int flag=0; FILE *fp; struct stu *p,*q,*h,*ww; ww=(struct stu *)malloc(LEN); if((fp=fopen(www.txt,r))==NULL) { printf(con not open this file\n); exit(0); } for(i=0;fread(ww-student,len,1,fp)==1;i++); rewind(fp); for(j=0;ji;j++) { n=n+1

文档评论(0)

1亿VIP精品文档

相关文档