I want this program to break from the switch and back into the while loop. Why isn't it working?
I put a switch statement within a while loop. I think the breaks are interfering with the while loop making it break early. How could I fix this problem?
#include <stdbool.h>
#include <stdio.h>
int main(void)
{
bool ON_status = true;
char option = '0';
while (ON_status == true)
{
printf("enter option 1, 2, 3, or 4.\n");
printf("Select an option from the menu above then press the enter key: ");
scanf("%1s", &option);
switch (option)
{
case '1':
printf("option1 was selcted");
break;
case '2':
printf("option2 was selcted");
break;
case '3':
printf("option3 was selcted");
break;
case '4':
printf("option4 was selcted");
ON_status = false;
break;
default:
break;
}
}
return 0;
}