I am doing a school project which requires me to return to the menu after each option but I am currently having trouble with returning to the menu using a do-while loop as my while(true) has an issue with running due to the (true) being undefined. Please help!
do {
// print out menu
printf("================================== MENU ==================================== \n");
printf("HELLO PLEASE CHOOSE 1 OPTION BELOW: \n");
printf("(1) CO2 reading and health advisory descriptor of a given classroom and time \n");
printf("(2) 3 hourly average CO2 reading for a selected classroom \n");
printf("(3) Highest CO2 reading from the classroom for a selected time \n");
printf("(4) Top 3 unhealthy readings for a selected classroom \n");
printf("(5) List of time periods and classroom with above 'Average' value \n");
printf("(6) The unhealthiest classroom CO2 reading from 7am to 11am \n");
printf("============================================================================ \n");
printf("\n");
// getting user input
printf("Please enter your option: ");
int userInput;
scanf_s("%d", &userInput); // put the user input into int userInput
printf("\n");
// check for the user input and run the function accordingly
switch (userInput)
{
case 1: // if the user press 1
{
// call option1 function
option1();
break;
}
case 2:
{
// call option2 function
option2();
break;
}
case 3:
{
// call option3 function
option3();
break;
}
case 4:
{
// call option4 function
option4();
break;
}
case 5:
{
// call option5 function
option5();
break;
}
case 6:
{
// call option6 function
option6();
break;
}
}
} while (true);
Why is this so?