I'm currently trying to find a word inside a string. I'm using string::find()
. However this only finds the word in the string for one time.
string a = "Dog";
string b = "I have a dog, his name is dog";
if (b.find(a) != string::npos)
{
...
}
Is there a way to scan string b
to see how many times the word "dog" appears?