I am a little lost i am trying to find all occurrences of a string inside a string.
If I have for example
and I wanted to find all instances of the word John in the previous quote.Code:string quote = "John loves Suzy. Suzy doesnt love John. Suzy loves Grover. John does not like Grover. "
i think this is close but i am not sure
I am desperately trying to learn can anyone help?Code:int position = quote.find("John", 0);
while (position != string::npos)
{
j++
}
cout << "The number of times John was used is: " << j++;