I’m trying to compare a string with a const char*.
std::string line;
std::fstream tmpl;
I fill the string variable with some input from an fstream file using getline:
getline(tmpl, line);
and then I want to compare the line with something e.g.:
if(line == "$something")
for some reason it always returns false.
I tried a lot of different things already but without success (either having it return always false or always true)
Why and how do I fix this issue? Did I miss something? Is getline not the right approach?
Problem fixed using string.find(). I misused it when I tried different things. However the question about comparing with == is still open.
Ok Now try the below code…