为什么输入的时候会多输出一行
程序代码:
#include"include.c" #include"struct.c" #include"file.c" int main(){ FILE *f; User *u; char f_name[20]; printf("scanf open file name:"); gets(f_name); f = fopen(f_name,"ab+"); while(!feof(f)){ u = (User *)malloc(sizeof(User)); fread(u,sizeof(User),1,f); printf("%s\t%d\t%s\n",u->name,u->age,u->f_word); } fclose(f); }
用fwrite保存一行数据后 输出会多输出一行
如
输入 name 20 lelelele
输出 name 20 lelelele
0