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!)
精彩评论