here is the code
int miscellaneous::printWelcomeScreen(){
int ch;
cout<<"Tic Tac Toe"<<endl<<endl;
cout<<"1. Play Game "<<"2. How to Play "<<"3. Credits "<<endl;
cout<<endl<<"Enter Your Choice"<<endl;
cin>>ch;
choiceSelection(ch);
return 0;
}
int miscellaneous::choiceSelection(int ch){
switch(ch){
case 1: break;
case 2: showHelp();break;
case 3: showCredits();break;
default: {
cout<<"Wrong Choice dude!! Use your keyboard Properly next time";
printWelcomeScreen();
break;
}
}
return 0;
}
When I give a int input, default case works perfectly, But when I give a char input, default case starts running in infinite loop.
Why this is happening? I even tried parsing ch before passing to switch.