Actually, it does not give int , it gives char (because the iterator of the string iterates over the characters in the string). Since the other operand != Is not char (it is a const char[2] ), the standard arguments and conversions apply to the arguments:
char advances to int through integral advertisingconst char[2] converted to const char* by converting the array to a pointer,
This is how you get into the operands of int and const char* , with which the compiler complains.
You should compare a dereferenced iterator with a character, not a string:
cout << ((*i) != 's') << endl;
"" contains a string literal (type const char[N] ), '' encloses a character literal (type char ).
Angew source share