I'm new to C++.
string str = "WWWHBBB";
if(str[mid] == "H" && str[0] != "W") return; // corrected after comments for second operand
The above line with if
condition gives me an error.
Comparison between pointer and integer ('std::__1::basic_string, std::__1::allocator >::value_type' (aka 'char') and 'const char *')
I have searched the internet enough to know that array style access is fine in strings. Error basically is pointing out comparison about pointer and integer. Really? I thought I was comparing character H
to another character in string str
.
I tried if str[mid]
really returns an iterator I should do *str[mid]
. Nah! Didn't work either.