[Dev-C++] Case statement - it SHOULD work...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2002-04-07 12:04:18
|
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
|