Switch Help

I keep getting the error "case value has already appeared in this switch" how do I fix this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
switch (selection)
		{
		case 'A' || 'a':
			aFunc(Houses);
			break;
		case 'B' || 'b': //The error is here
			bFunc(Houses);
			break;
		case 'C' || 'c': //The error is here
			cFunc(Houses);
			break;
		case 'D' || 'd': //The error is here
			dFunc(Houses);
			break;
		case 'E' || 'e': // The error is here
			eFunc(Houses);
			break;
		}




Any suggestions?
Last edited on
Simple rules for logic operator evaluation: any integral value which is not 0 converts to true, 0 converts to false. As char is of integral type and 0 is denoted as '\0', your case labels are actually:
1
2
'A' || 'a' == 1
'B' || 'b' == 1

You need to separate labels for 'A' and 'a', etc.
Ok I got it, so how would I rewrite this while still calling the same functions?
Same as you have it now. You just separate it in two different case labels:
1
2
case 'A':
case 'a':
Topic archived. No new replies allowed.