第9章 文件(修改).pptVIP

  • 21
  • 0
  • 约1.17万字
  • 约 68页
  • 2016-09-20 发布于江西
  • 举报
第9章 文件(修改).ppt

#includestdio.h #include stdlib.h struct St { char name[10]; int num; int age; char addr[15]; }stud[10]; 第9章 文件 int main() { int i; FILE *fp; if((fp=fopen(“stu.dat”,“rb”))==NULL) { printf(can not open file\n); exit(0); } for(i=0;i10;i+=2) { fseek(fp,i*sizeof(struct St),0); fread(stud[i], sizeof(struct St),1,fp); printf(“%-10s %4d %4d %-15s\n”, stud[i].name,stud[i].num, stud[i].age,stud[i].addr); } fclose(fp); return 0; } 第9章 文件 9.5 文件读写的出错检测 1.ferror函数 ferror函数的一般调用形式为 fe

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档