Comapring string in Switch case

Hi all,
Is there any way by which we can compare strings using switch-case method?
Or will we have to use only if-else?
The following code gives error & which is perfect because swtch expects an integer and not any string.

char action[] = "hello";
switch(action)
{
case "hello":
cout<<"hi";
break;
default:
break;
}

Thanks,
Samar..
you are completely wrong my friend!!Switch case has nothing to do with what you have come up with!!You have to call strcmp() ,store the reutrn result and then call switch using that integer variable.
Topic archived. No new replies allowed.