hey people this is not so much a problem rather than curious question
so I run the code below and I get the following error
error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|
how come when you dereference the iterator which points to a string it has to be in single quotes rather than double?
also the error message message is quite cryptic how are we comparing a pointer to an integer sure we are comparing a char to a string or a string to a string?
if I remove the double quotes " t " and put single quotes for a char it works fine
(ps yes this is a silly way to remove a character from a string when we could use string.erase overloaded function with a string instead of an iterator but just doing it for fun)
thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main(){
for(string::iterator it = str.begin(); it != str.end();){
if(*it == "t"){
it = str.erase(it);
}else{
it++;
}
}