void InputFunction()
{
system("cls");
printf("\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\t\t *** ***\n");
printf("\t\t *** WELCOME TO ***\n");
printf("\t\t *** CLASS ATTENDANCE SYSTEM ***\n");
printf("\t\t *** ***\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\n\n");
fflush(stdin);
printf("\t\t What Is The Course Code? ");
scanf("%s", SubCode);
fflush(stdin);
fflush(stdin);
printf("\t\t How Many of The Total Weeks? ");
scanf("%d", &week);
while(isalpha(week))
{
fflush(stdin);
printf("\t\t You Have Enter Out of Range\n");
printf("\t\t Please Re-enter Again\n");
printf("\t\t How Many Weeks? ");
scanf("%d", &week);
}
printf("\t\t How Many Students In This Class? ");
scanf("%d", &student);
while(isalpha(student))
{
fflush(stdin);
printf("\t\t You Have Enter Out of Range\n");
printf("\t\t Please Re-enter Again\n");
printf("\t\t How Many Students In This Class? ");
scanf("%d", &student);
}
Let's assume the user input alphabet, it should goes into the while loop and scanf again right.?
but my code is doesn't work like that, if user input invalid input, the program will straight away jump back to the beginning..
why? any problem with my code?