In this case I would've used a switch statement ie:
Code:
while(1){
printf("\n\tStudent Files\n");
printf("\n1\tEnter Student Information\n");
printf("\n2\tPrint Student Information\n");
printf("\n3\tQuit\n");
printf("Select an option: ");
response = getchar() - '0';
switch(response){
case 1:
printf("\nEnter first name: ");
...
break;
case 2:
pRead=fopen("student_files.dat", "r");
...
break;
case 3:
printf("Exiting\n");
return 0;
default:
printf("\nInvalid Selection\n");
}
}
For your fscanf(stdin, "%d", &some_var); you might want to use the
%f conversion, and find it produces better results.
For an exit check, just extend your if() checks, but as I mintioned earlier, for this I would rather use some form of switch() clause.
Code:
if(response == 3)
{
printf("Exiting\n");
return 0;
}