正在加载图片...
第13章第4节 for(i=0;i<3;i++) Printf("input data of s[%d: ,i); scanf("%d %s %d %d %d",&si]. no, s[]. na, &s]. sc[0), &si sc[1, &si sc 2 ) sIi ave=(float(sisc[0+si]. sc[1+si sc[2 )/3.0; fwrite(&sil, sizeof(struct student), 1, fp); fclose(fp) if(fp=fopen("a: filel. txt,rb ==NULL) Printf( n can not open the file in ) exit(0); 3 for(i=0;i<3;i++) ffread(&s i, sizeof(struct student), 1, p); printf("%d %s%d %d %d%7.1f\n si. no, si na, sisc0 sisc1,si sc2, si ave); fclose(fp)for(i=0; i<3; i++) {printf("input data of s[%d]: ", i); scanf("%d %s %d %d %d", &s[i].no,s[i].na,&s[i].sc[0],&s[i].sc[1],&s[i].sc[2]); s[i].ave=(float)(s[i].sc[0]+s[i].sc[1]+s[i].sc[2])/3.0; fwrite(&s[i],sizeof(struct student),1,fp); } fclose(fp); if((fp=fopen("a:\\file1.txt","rb"))==NULL) {printf("\n can not open the file\n"); exit(0);} for(i=0; i<3; i++) {fread(&s[i],sizeof(struct student),1,fp); printf("%d %s %d %d %d %7.1f\n", s[i].no,s[i].na,s[i].sc[0],s[i].sc[1],s[i].sc[2],s[i].ave); } fclose(fp); } 第13章第4节
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有