while(mpick != 4)
{
type_fast("Main Menu\n\n");
type_fast("1. New Game\n");
type_fast("2. Load Game\n");
type_fast("3. Options\n");
type_fast("4. Exit Game\n");
cin >> mpick;
switch(mpick)
{
case 1:
{
break;
}
case 2:
{
break;
}
case 3:
{
break;
}
case 4:
{
type_fast("Exiting Program...Press ENTER to Exit...\n\n");
cin.ignore();
cin.get();
break;
}
default:
{
type_fast("\nYour choice is invalid. Press ENTER to continue...\n\n");
cin.ignore();
cin.get();
}
}
This loop seems simple enough....everything works as intended. One thing I DO NOT understand is this...if for "mpick" the user inputs a char/string, basically anything other than an integer, the loop becomes recursive...just loops forever and ignores cin >> mpick;
Can anyone explain why it would do that and lead me in the right direction to error checking for that...also, I would really prefer "hints" per se...vs the actual code to finish this...I gotta learn some how and just giving the answer in code makes me lazy...I don't want to be lazy. :)
Edit: for all intensive purposes, mpick was not assigned anything prior to running...
mpick is an integer, correct? In that case, trying to read a character into it will cause cin to enter an error state where it will no longer read until you clear it. A simple fix would be to simply read a character (which can hold anything, including a number) and switch on that.
Note: the phrase is "for all intents and purposes", not "for all intensive purposes"