tags:

views:

49

answers:

3

I have created a function that has as input a char szMyChar; (using it in a switch statement).

Now I have a CString having just a char, lets say CString strString = "A";

An option to call the function could be:

if (strString == "A")
 CallMyFunc('A');

though it is clumsy. I tried atoi (returns 0) and casting though neither works.

Any ideas?

Thanks, Sun

+6  A: 

Either I'm not quite understanding what you're asking, or it's as simple as:

CallMyFunc(strString[0]);

See Accessing Individual Characters in a CString for more information.

Greg Hewgill
+4  A: 

Try

CallMyFunc(strString[0]);

The [] operator can be used to access individual characters just as with C strings.

Martin B
+4  A: 

Can you just do

CallMyFunc(strString[0]);

?

psmears