Hi,
Can we ask you not to start a new topic, when the question is related directly to the code you had in a previous topic, just keep the same topic going.
I have a personal hatred for constructs like this, the are error prone,
UGLY, unnecessary, and non scalable:
while(choice != 'C' && choice != 'c');
Instead, provide a Quit option in your menu, and in the switch. And a while loop can run on a
bool
Quit value.
1 2 3 4 5 6 7
|
bool Quit = false;
while (!Quit) {
// menu
//switch
}
|
The
default:
case catches bad input.
There is no need for a
return
statement in a void function, unless you wish to return early.
Otherwise if you ever use a
do
loop, put the while condition on the same line as the closing brace. This is so it doesn't look like a
while
loop with a null statement.
I am not a fan of
do
loops either: I find the need for them is fairly rare and they can be error prone. Just because they always execute once should not be the sole reason to use them. All 3 types of loop can be converted from one to another, maybe at the price of an extra variable.
@
mgoetschius
That's wrong, and shows how confusing these things are. I won't describe how to do that type of statement, because that might encourage someone else to use it. Personally, I think that those who teach this non-sense need their collective asses kicked: preferably with steel capped boots; or until the kicker has webbed feet !! I mean that in the nicest possible and comedic way :+)