Benjamin_Barrett
asked on
Calling main() within main()
Following on from my question here
https://www.experts-exchange.com/questions/21925676/Using-'enter'-to-return.html
How can I get my program to return to the main menu, without calling main()?
I do this elsewhere in the program, but always within other functions that main has called....
https://www.experts-exchange.com/questions/21925676/Using-'enter'-to-return.html
How can I get my program to return to the main menu, without calling main()?
I do this elsewhere in the program, but always within other functions that main has called....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK...
wouldnt the do loop be inside the switch statement?
ie switch(option)
case '1'
printf("Enter a string (1-5 characters): ");
fgets
do
{
stuff
}while(!NULL)
wouldnt the do loop be inside the switch statement?
ie switch(option)
case '1'
printf("Enter a string (1-5 characters): ");
fgets
do
{
stuff
}while(!NULL)
ASKER
Sorry, meeting back in 1/2 hour
> wouldnt the do loop be inside the switch statement?
nop. Then then you will need loops inside each case. Also you will not be able to ask for options.
Sunny's idea would be the best.
regards
Manish Regmi
nop. Then then you will need loops inside each case. Also you will not be able to ask for options.
Sunny's idea would be the best.
regards
Manish Regmi
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
With a rewrite I managed this working nicely.
Thanks heaps for your help guys
Benjamin
Thanks heaps for your help guys
Benjamin
do
{
print (option a)
print (option b)
...
print (option n)
read (user_option)
if (user_option was "\n" )
continue
switch (user_option)
{
case option a:
....
case option b:
....
case option n:
...
default:
print unknown option
}while (user_option was not quit)