📄 13-5.cpp
字号:
#include <stdlib.h>
#include<stdio.h>
struct student_type
{ char name[10];
int num;
int age;
char sex;
}stud[10]; main()
{
int i;
FILE *fp;
if((fp=fopen("stud-dat","rb"))==NULL)
{printf("can not open file\n");
exit(0);}
for(i=0;i<10;i+=2)
{
fseek(fp,i*sizeof(struct student_type),0);
fread(&stud[i], sizeof(struct student_type),1,fp);
printf("%s %d %d %c\n",stud[i].name,stud[i].num,stud[i].age,stud[i].sex);
}
fclose(fp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -