Các bác chỉ ra tại sao giúp em tại sao in ra lại bị x2 dòng ạ !!
Code:
void importfile(FILE *fp){
history h;
h.year = malloc(sizeof(int)*6);
h.content = malloc(sizeof(char)*50);
int i=1;
puts("-----------------Historic Events--------------- \n");
while(1){
int choice;
puts("Milestone : ");
scanf("%d",&h.year);
puts("Brief content :");
fflush(stdin);
gets(h.content);
fprintf(fp,"%d.Nam %d %s\n",i,h.year,h.content);
puts("Tiep tuc : 1 Thoat : 2"); scanf("%d",&choice);
if(choice==2){
break;
}
i++;
}
}
void readfile(FILE *fp){
history h;
h.year = malloc(sizeof(int)*6);
h.content = malloc(sizeof(char)*50);
puts("\nLet me see the file");
int i=1;
while(!feof(fp)){
fscanf(fp,"%d",&h.year);
fgets(h.content,50,fp);
printf("%d.Nam %d %s\n",i,h.year,h.content);
i++;
}
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?