Is it possible to make a switch-case with char arrays?
I am trying with this piece of code:
char *value;
...
switch (value) {
case "John":
printf("Your name is John\n"
;
break;
case "Tom":
printf("Hello, Tom!\n"
;
break;
}
But I get this error:
<<error C2450: switch expression of type 'char *' is illegal
Integral expression required >>
Any help?
I am trying with this piece of code:
char *value;
...
switch (value) {
case "John":
printf("Your name is John\n"
break;
case "Tom":
printf("Hello, Tom!\n"
break;
}
But I get this error:
<<error C2450: switch expression of type 'char *' is illegal
Integral expression required >>
Any help?