switch case error

closed account (4jzvC542)
Here is my code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  //swich.cpp
//using swich statement
#include <iostream>
using namespace std;
int main()
{
	char ch;
	cout << "Enter a character : \n";
	cin >> ch;
	switch(ch)
	{
		case "a" :
		case "A" : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case "e" :
		case "E" : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case "i" :
		case "I" : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case "o" :
		case "O" : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case "u" :
		case "U" : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		default  : cout << "You have not entered a vowel please try again with vowel \n";
	}
	return 0;
}

it does not compile sucessfully and shows following error :

case label does not reduce to an integer constant

i am using Quincy 2005 compiler
where am i struct and what is wrong with my code
parjanya
case 'a' not case "a"
closed account (4jzvC542)
Ohhhhh very damn stupid of me !!!!!! :(
@Mobotus
thanks for pinting it out......so stupid i was..........
now final working code is :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//swich.cpp
//using swich statement
#include <iostream>
using namespace std;
int main()
{
	char ch;
	cout << "Enter a character : \n";
	cin >> ch;
	switch(ch)
	{
		case 'a' :
		case 'A' : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case 'e' :
		case 'E' : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case 'i' :
		case 'I' : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case 'o' :
		case 'O' : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		case 'u' :
		case 'U' : cout << "Character you have entered : " << ch <<" is a Vowel." << endl;
				   break;
		default  : cout << "You have not entered a vowel please try again with vowel \n";
	}
	return 0;
}

thanks man....................
Topic archived. No new replies allowed.