I am learning C file handling. I wrote the following program so the user can enter a student’s id and name. But the issue is instead of asking for 2 inputs from the user it is expecting me to input three times… Here is the code. What is the issue?
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');
Thanks..
You should not have the \n in the scanf string.