searching a ifstream for a string
i have this code...but i'm not sure why it isn't working, when i pick a string to search for i alway sget a really high number like 15 - 30 even though there probobly isn't more than 1 or 2 cases where string exists in the file.
Code:
void searchstring(ifstream& in, string search)
{
string word;
int count=0;
while (!in.eof())
{
in >> word;
if (word.find(search))
count++;
}
cout << "# of Search String "<<search<<" : " << count << endl;
}
the file i'm searching has the word "Jill" in it twice and when i search for it i get back 29...
any ideas?