string::find double quote Problem

I can't seem to understand why the code below enters the if statement:

1
2
3
4
5
6
7
8
9
10
size_t found;
string after_token = "\"testing testing testing\"";

found=after_token.find("\"");
if (found==string::npos){
cerr << "Payload not enclosed in double quotes\n on line: " << num_hops + 1 + input_payloads_count << ". Please check input:\n" << endl;
cerr << usage << endl;
exit (1);
}
after_token.erase(found);


I am trying to locate the first double quote in the string after_token so that I can erase it. My understanding is that "\"" should be the correct representation of an escaped double quote string literal. What am I doing wrong?
There is nothing wrong with the code above. Is there any more of it?
the problem was that I was erasing the entire line.

I changed the last line to:

after_token.erase(found,1);

to only erase the double quotes and not the whole line.

Topic archived. No new replies allowed.