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:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<iostream.h>
int opcio1();
int opcio2();
int opcio3();
void 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;
}
}
void opcio1(){
cout <<"How to\n\n"<<endl;
}
void opcio2(){
cout <<"Sudoku generator\n\n"<<endl;
}
void opcio3(){
cout <<"Play\n\n"<<endl;
}
This code works.
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