i have so many functions in my program,what i want to do is, i want to return back to the main() but in somewhere middle of it!.
should i use goto statements?
i tried 'em,it gave some error!
if i should use goto then please explain how to,thanks
Printable View
i have so many functions in my program,what i want to do is, i want to return back to the main() but in somewhere middle of it!.
should i use goto statements?
i tried 'em,it gave some error!
if i should use goto then please explain how to,thanks
You should design your program so that this isn't necessary, that's how.
When you return from a function, control returns to the statement right after your call to the function. So, if you call a function from main, you'll return there.
i want to return to the lines above ,where i call the function,i cant design my program.
i want to return to a menu which is in the main and if the user wants to run the function again then he can select it again from the main
Basically do something like:
Code:int main( )
{
bool shutdown = false;
while (!shutdown)
{
switch (ShowMenuFunction( )) // returns the selected menu option
{
case 0:
DoMenuOptionZeroFunction( );
break;
case 1:
DoMenuOptionOneFunction( );
break;
case N: // assuming option N is 'exit'
shutdown = true;
break;
};
}
return 0;
}