fopen在预处理改了也不行,运行中断,怎么解决?
vs2015吧
全部回复
仅看楼主
level 5
aing123123 楼主
#include"stdio.h"
#include"stdlib.h"
void main()
{
FILE *fp;
struct student
{
char num[8];
int score;
}
stud[] = { { "101",86 },{ "102",60 },{ "103",94 },{ "104",76 },{ "105",50 } }, stud1[5];
int i;
if ((fp = fopen("stud.bin", "wb+")) == 0)
{
printf("不能打开文件\n");
exit(0);
}
for (i = 0; i < 5; i++)
fwrite(&stud[i], sizeof(struct student), 1, fp);
rewind(fp);
printf("学号 成绩\n");
while (!feof(fp))
{
fread(&stud1[i], sizeof(struct student), 1, fp);
printf("%s %d\n", stud1[i].num, stud1[i].score);
}
fclose(fp);
}
2016年06月13日 07点06分 1
1