Re: [Dev-C++] Case statement - it SHOULD work...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jason S. <mys...@op...> - 2002-04-07 12:24:22
|
The following works fine. I'm guessing you were doing something weird in
the switch statement, like saying case '1'.
Jason
int main()
{
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 1 : cout << "Confirmed - Creating Employee...\n";
break;
case 2 : cout << "Confirmed - Changing wage...\n";
break;
case 3 : cout << "Exiting...\n";
break;
default : cout << "ERROR!!!!!!!!!!!!!!!!\n"; break;
}
}while(Choice > '3' || Choice < '1');
return 0;
}
----- Original Message -----
From: "Daniel Glenfield" <sp...@ho...>
To: <dev...@li...>
Sent: Sunday, April 07, 2002 8:04 AM
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?
>
-users
|