I always forget how to do this the correct way, and always end up whith the same error. Its a simple problem, and I'm sure the solution is very obvious.
int main()
{
do
{
int foo = baz(); // return value
switch(foo)
{
case 1:
//...
break;
case 2:
//...
break;
//...
default:
//...
}//END switch
}while(foo != 0); //END do while <-ERROR
}//END main
Error:
'foo' was not declared in this scope
I know variables only survives inside the scope, but how do I get pass this problem?
The baz() function is a menu which I want to be displayed using the do while loop. And the return value (the menu choice) should be tested in the switch...