开发者

Get a char from a CString

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


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.


Try

CallMyFunc(strString[0]);

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


Can you just do

CallMyFunc(strString[0]);

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜