C语言程序设计朱建芳第12章课件教学.pptVIP

  • 4
  • 0
  • 约1.11万字
  • 约 57页
  • 2017-01-02 发布于未知
  • 举报

C语言程序设计朱建芳第12章课件教学.ppt

/*exam12-6*/ main() { FILE ﹡fp; int i; struct teacher { long num; char name[20]; int age; float salary; }tea; /*定义结构体变量tea*/ fp=fopen(“teacher.dat”, “rb”); if(fp= =NULL) { printf(“Can not open the file\n”); exit(0); }else{ fseek(fp,1*sizeof(struct teacher),0); fread(tea,sizeof(struct teacher),1,fp); printf(“Num:%ld Name:%s Age:%d Salary:%f\n”, tea.num, , tea.age,tea.salary); fclose(fp); } } Num:1012 Name:ZhangLei Age:27 Salary:2700.0 程序运行结果为: 12.4.2 返回文件当前位置ftell(

文档评论(0)

1亿VIP精品文档

相关文档