Problems with switch statements

My switch statement goes straight to default. Can anyone help.

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
31
32
33
34
35
36
    char Topic1 [20];
   cin>>Topic1;

   switch(*Topic1)
   {

   case('Trigonometry'):
       case('trigonometry'):
{


PlaceCursor(65, 7); printf("Trigonometry");
system("CLS");
Trigonometry Trigonometry;
break;
   }
   case('Pythagoras'):
{

   PlaceCursor(65, 7); printf("Pythagoras");
       system("CLS");
    Pythagoras Pythagoras;
break;
}
   case('NumberBonds'):

{
        PlaceCursor(65, 7); printf("Number Bonds");
       system("CLS");
     NumberBonds NumberBonds;
     break;
}
default :
    cout<<"Failed";
    break;
   }

Thanks
Well, because you are trying to compare single char to implementation defined value of multicharacrer literal.

You cannot have switch cases to be strings. Use if/else ifs and strcmp() to achieve what you want
Topic archived. No new replies allowed.