注:fwrite(),fread -可对数据块读写,且数据为二进制,文本下查看为乱码,文件的打开方式为 “b*”
实例:
写入二进制数据
for (int i = 0; i < SN; i++){
fwrite(&stds[i],sizeof(student),1,file);
}
检测用fread
for (int i = 0; i < SN; i++){
fread(&ss[i], sizeof(student), 1, file);
printf("id:%d,name:%s,a:%f,b:%f,c:%f ", ss[i].id, ss[i].name, ss[i].a, ss[i].b, ss[i].c);
}