But if the user put by wrong 'b' instead Y or N.. it will be as he hits Y ???
I'm sure you could figure that out???
Code:
while(1)
{
printf("Enter number of field: \n");
fgets(temp, sizeof(temp)-1, stdin);
sscanf(temp, "%d", &nfield);
printf("Are you sure %d fields \n",nfield);
while((sure = tolower(getch())) != 'y' && sure != 'n');
if(sure == 'n')
continue; /* start loop again */
else
break; /* leave loop */
}
The inner while loop won't stop unless a y or n is input, it does everthing on one line as well, which is cool.