so basically i wrote a progarm that begins with a menu allowing you to select one of 5 functions, but at the end of whichever function i would like it to return to the menu
the problem is i dont know how to do that and would like any tips or if any of you would be so kind as to clue me in on how to do it
im fairly certain it has to do with the return statement but am not sure how
thank you
jeremy62
0
Newbie Poster
Recommended Answers
Jump to Postso basically i wrote a progarm that begins with a menu allowing you to select one of 5 functions, but at the end of whichever function i would like it to return to the menu
the problem is i dont know how to do that and would like any tips …
Jump to PostOr you could try something like this:
#include <stdio.h> #include <stdlib.h> int main(void){ while(1){ system("cls"); int opc; bool process=false; printf("Select an option:\n"); printf("1. Option A:\n"); printf("2. Option B:\n"); printf("Option: "); scanf("%d",&opc); if(opc > 0 && opc < 3) process=true; if(process){ //do something printf("\n\nDOING SOMETHING!"); }//else let it …
Jump to PostYou can use a simple switch ..
May be like this..#include <stdio.h> int main(void){ while(1){ int opc; printf("What u want to do?\n"); printf("1. smthing\n"); printf("2. smthing\n"); printf("Your Choice: "); scanf("%d",&opc); switch(opc) { case 1 : FirstFunction(); break; case 2 : SecondFunction(); break; .. .. .. default: …
All 10 Replies
vanalex
0
Junior Poster in Training
darkbreaker
33
Newbie Poster
Shankye
36
Junior Poster
Kamatari
1
Light Poster
Adak
419
Nearly a Posting Virtuoso
vinitmittal2008
37
Junior Poster
Shankye
36
Junior Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Shankye
36
Junior Poster
Shankye
36
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.