char mingzi[20]; char nianling[3]; float score[6]; }data,info[1000]; int i,j,k=0;
char temp[20],ch; FILE *fp,*fp1;
void shuru() {
if((fp=fopen("s_score.txt","ab+"))==NULL) /*以读写方式打开名为s_score的文件*/ {
printf("cannot open this file.\n"); getch();exit(0); }
for(i=0;i<=1000;i++) {
printf("\nPlease shuru xuehao:"); gets(data.xuehao);
printf("Please shuru mingzi:"); gets(data.mingzi);
printf("please shuru nianling:"); gets(data.nianling);
printf("Please shuru shuxue score:"); gets(temp);data.score[0]=atof(temp); printf("Please input yingyu score:"); gets(temp);data.score[1]=atof(temp); printf("Please shuru wuli score:"); gets(temp);data.score[2]=atof(temp);
data.score[3]=data.score[0]+data.score[1]+data.score[2]; fwrite(&data,sizeof(data),1,fp); printf("another?y/n"); ch=getch();
if(ch=='n'||ch=='N') break;
} fclose(fp); /*读文件结束*/ }
void xianshi() {
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL) /*以读写方式打开名为s_score的文件*/ {
printf("Cannot reading this file.\n"); /*先检查打开的操作是否出错*/