开发者

What is the proper way to compare an element of an std::string with a character?

I am not a very experienced C++ p开发者_开发百科rogrammer, i get a warning when i do the following:

if (myString[i] != 'x')
{
}

what is the appropriate way to compare these?

thanks for your help!


possibility 1: the int that identifies the element in the array should not be larger than a regular int.

possibility 2: If myString is of type std::wstring the appropriate comparison is myString[i] != L'x' (ty popester!)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜