Hi I'm making a menu in C++ for a sudoku puzzle solver program I've already wrote using switch setence.
I've wrote that code:
This code works.Code:#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<iostream.h> int opcio1(); int opcio2(); int opcio3(); int main(){ char sel; cout <<"Sudoku\n\n\n"<<endl; cout <<"1. How to\n\n"<<endl; cout <<"2. Sudoku generator\n\n"<<endl; cout <<"3. Play!\n\n"<<endl; cout <<"4. Exit\n\n"<<endl; cout <<"Select an option, please..."<<endl; do{ sel=getch(); }while((sel<'1' || sel>'4')&&sel!=27); //esc=ASCII 27 switch(sel){ case '1': opcio1(); break; case '2': opcio2(); break; case '3': opcio3(); break; case 27: return; } } int opcio1(){ cout <<"How to\n\n"<<endl; } int opcio2(){ cout <<"Sudoku generator\n\n"<<endl; } int opcio3(){ cout <<"Play\n\n"<<endl; }
My question is how to do a return to the menu option inside every option in the menu?
I've tried to use goto but it only works for inside the same function.
Thank you



LinkBack URL
About LinkBacks



(this is supposed to be another semicolon and a right paren not a smiley face) loop, include your menu and the do while statement - add an appropriate break after the while line.
, to your original question. Since your functions (opcio1, opcio2, etc.) are not void, they're supposed to return a value.