I have the code below as part of a C program to change direction. Whenever I run the code, the output is always the case followed by the default. Why is this happening and how can I stop the default showing every time?
Thanks
Output Example:
Enter command: W
Sorry, You can't go that way. Please enter another direction: Sorry, that's not a direction. Please enter either N, E, S or W:
printf("\nEnter command:"); while (1) {
scanf_s("%c", &ch);
switch (ch)
{
case 'w':
case 'W':
printf("\nSorry, You can't go that way. Please enter another direction:");
break;
case 's':
case 'S':
printf("\nSorry, You can't go that way. Please enter another direction:");
break;
case 'e':
case 'E':
printf("\nSorry, You can't go that way. Please enter another direction:");
break;
case 'n':
case 'N':
case 'q':
case 'Q':
printf("Goodbye!\n");
exit(0);
default:
printf("\nSorry, that's not a direction. Please enter either N, E, S or W:");
break;
}
}