If user enter 1, I would want them to go to 1, where there is another place for them to input 'data' into arrays.
@TheIdeasMan, i understand your point for the while loop, if there is more than 15 options, i'll be dead i guess!
Thanks for the help on the latest coding.
And also, i read up about parsing a char string[255] to check for characters being entered.
If 'a' is entered, i will end up in an infinite loop again. I read up on tutorials but do not know how to apply it. Can you enlighten me? I see it something about std::String..
char menuChoice; // char not int, so we can have a quit option
//bool repeat=false;
bool Quit = false;
Test test;
while ( !Quit ) {
test.mainMenu();
cout<<"Please enter your choice : ";
cin>>menuChoice;
menuChoice = toupper(menuChoice);// so we can have q or Q without testing twice
switch(menuChoice) {
case'1':
cout<<"You choosen 1"<<endl;
break;
case'2':
cout<<"You chose 2"<<endl;
break;
case'3':
cout<<"You chose 3"<<endl;
break;
case'4':
cout<<"You chose 4"<<endl;
break;
case'Q':
cout<<"You have chosen to Quit"<<endl;
Quit = true; //program continues after the end of the while
//could use exit(0) function to quit altogether
break;
default:
cout<<"Invalid entry!"<<endl;
//repeat=true;
break;
}
}
This is even simpler - I have got rid of the repeat variable. Now it should loop until the user enters q or Q.
It should be obvious that each case clause would have a function call to carry out that particular action.
Also, this whole thing should be in the class. You could even have a CMenu class, as well as any other class you might need to do the application.