- 2
- 0
- 约1.1万字
- 约 35页
- 2017-06-29 发布于浙江
- 举报
c语言程序设计-朱建芳第12章
/*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.name, tea.age,tea.salary); fclose(fp); } } Num:1012 Name:ZhangLei Age:27 Salary:2700.0 程序运行结果为: 12.4.2 返回文件当前
原创力文档

文档评论(0)