this code works ok until i type say a letter. like if i typed 789 it works fine. if i type say the letter a or a word or anything with a char in it, it then tells me that the monster doesn't exist, which it should, but then repeatedly keeps looping through my program coming to this function and telling me that the monster doesn't exist. Surely there is a way to make sure a number is typed and not a letter?????
Thanks for your time.....
werdy666
Code:void viewmonsterstat() { int answer=0; cout << "Which monsters stats would you like to view?" << endl; cout << "--------------------------------------------" << endl << endl; cout << "1. " << bad[0].name << endl; cout << "2. " << bad[1].name << endl; cout << "3. " << bad[2].name << endl; cout << "4. " << bad[3].name << endl; cout << "5. " << bad[4].name << endl << endl << endl; cin >> answer ; switch(answer) { case 1: viewcurrentmonster(answer-1); return; break; case 2: viewcurrentmonster(answer-1); return; break; case 3: viewcurrentmonster(answer-1); return; break; case 4: viewcurrentmonster(answer-1); return; break; case 5: viewcurrentmonster(answer-1); return; break; case 0: default: cout << "That monster doesn't exist!" << endl; Sleep(1000); return; break; }// end switch } // end function