Hi, I am writing a console application that gives the user a list of options to choose from. Viewing the code below, when the option "0 - Exit" is selected my code does not run the if statement for when "0" is entered and the loop is infinite. Can anyone please advise me as to why this is?
A conditional statement will be considered true if it converts to anything other than zero.
So Line 17 is equivalently, "while (user_selection != 0)". user_selection is 0, so the inner while loop will not be entered.
Even if the inner while loop were to be entered, your if statement on line 19 would cause the inner while loop to break, so your if statement on line 92 would never be reached.
And even if the if statement on line 92 were entered,
1 2 3 4
if (user_selection == 0)
{
EXIT_SUCCESS;
}
The above doesn't do anything.
EXIT_SUCCESS is just a macro for 0, so you're just writing: