This program is part of a large one and accessed via a switch statement. For some reason when I type in a Y or N at the prompt when running it, the program skips to the last else option and replies a 'not a valid option' when it should not. I have messed with it for ages and am not getting anywhere.
case 'I':;
{
char Y[]="Y";
char N[]="N";
char choice1 = 'Z';
k = 5 - j;
printf("\nThere are currently %i spaces in the data base", k);
if(j<5)
{
printf("\n\nEnter the Student's first name:\t\t ");
scanf("%s", studalltemp[j].fNametemp);
printf("\ndatabase. Please conform that these details are correct (Y/N)");
choice1 = getchar();
getchar( );
k = 0;
if (choice1 == 'Y')
{
printf("\n1 student record saved to file\n");
strcpy(studall[j].fName, studalltemp[j].fNametemp);
j++;
}
else
{
if (choice1 == 'N')
printf("Here");
else
printf("Not a valid option");
}
}
}
break;



LinkBack URL
About LinkBacks



Goddess love those minors::