In the following code in my program:
do
{
printf("\nEnter records of student %d: \n", i++);
printf("Name: ");
fgets(record.name, sizeof(record.name), stdin);
printf("\nAddress: ");
fgets(record.address, sizeof(record.address), stdin);
printf("\nClass Level: ");
scanf("%d", &record.classlevel);
printf("\nTelephone Number: ");
scanf("%ld",&record.telephone);
fwrite(&record, sizeof(record),1,fptr);
printf("\n\nAdd another record? [y/n]: ");
}while(getche()=='y');
When i see the output, It works fine for the first time
Enter records of student 1
Name: <some input>
Address: <some input>
Class Level: <some input>
Telephone Number: <some input>
Add another Record? [y/n]: <pressed Y>
Enter records of student 2
Name: < no cursor comes , cannot provide input here>
Address: <only can input here>
.
.
..... etc..
What's happening, Why am i not able to input Name after first iteration in the do...while loop. Is the getche() doing any problem?
Hoping your Help
Thanks in Advance