Please help out!!! CANNOT debug

I have no reason why it failed to debug?
Anyone can help please?!
#include <iostream>
#include <string>

using namespace std;

int main()
{
int optionValue = 0; string option;
cout << "WELCOME TO THE SIMPLE TEXT GAME!";
do
{
cout << "\n\nPlease select one of the following options:" << endl;
cout << " 1: Play \n";
cout << " 2: Help \n";
cout << " 3: Option \n";
cout << " 4: Quit \n";
cin >> option; optionValue = atoi( option.c_str() );
//atoi() converts a char * to an int. returns 0 if input is not an int.

if (optionValue == 0) cout << "ERROR: You did not enter an integer value?! Please try again!"<< endl;
else if( optionValue < 1 || optionValue > 4 )
cout << "ERROR: Invalid option selected! Please select from 1,2,3 or 4" << endl;
else
{
switch (optionValue)
{
case 1:
cout << "Play Option Selected!" << endl << endl;
break;
case 2:
cout << "Help Option Selected!" << endl << endl;
break;
case 3:
cout << "Config Option Selected!" << endl << endl;
break;
case 4: cout << "Quit Option Selected!" << endl << endl;
break;
}
}
} while( optionValue < 1 || optionValue > 4 );
return 0;
Just add include <cstdlib> if you want atoi to work.


I think you forgot to put curly braces in the if else condition.
Last edited on
I have no reason why it failed to debug?

You're saying that it compiled ok but that when you started a debug session you couldn't step through the code?

Or what?

Andy
Topic archived. No new replies allowed.