RE: [Dev-C++] Case statement - it SHOULD work...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-04-07 14:31:14
|
You obviously forgot the '' when you used the char type. '1', '2', '3'. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Daniel Glenfield > Sent: Sunday, April 07, 2002 2:04 PM > To: dev...@li... > Subject: [Dev-C++] Case statement - it SHOULD work... > > > Here's a quick bit of code. For some reason when I enter 1, > 2, or 3 I get > the ERROR!!!!! message. If I change Choice to a char type and > change 1 2 and > 3 to a b and c it works. > What's wrong? > > int main(int argc, char *argv[]) > { > using namespace std; > > int Choice; // Menu choice, as entered by user. > do > { > cout << "***** W E L C O M E *****\n"; > cout << "\nChoose one of the following...\n"; > cout << "1.Create Employee 2.Change wage 3.Exit\n"; > cin >> Choice; // Get user's choice > switch (Choice) // Beginning our case flow control statements > { > case 'a' : cout << "Confirmed - Creating Employee...\n"; > break; > case 'b' : cout << "Confirmed - Changing wage...\n"; > break; > case 'c' : cout << "Exiting...\n"; > break; > default : cout << "ERROR!!!!!!!!!!!!!!!!\n"; > } > }while(Choice > '3' || Choice < '1'); > > > _________________________________________________________________ > Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |