我正在学习C文件处理。我编写了以下程序,以便用户输入学生的ID和姓名。但问题是,而不是要求用户提供2个输入,它希望我输入三次......这是代码。有什么问题?
do
{
printf("Enter ID and Name of the student\n");
scanf("%d\n %s\n",&id, name);
fprintf(myfile,"%d %s", id, name);
printf("Are there any more students [y/n]");
}while(getch()=='y');
谢谢..
答案 0 :(得分:1)
你不应该在scanf字符串中有\ n。