Originally Posted by 7stud
An easier way to accomplish that is to read the entire line into a string type using:
getline(myIfstreamObject, myVarThatIsAStringType);
Then you use a string's find() function to search the string for "hi my".
Continuing with the above suggestion, you would use find() to search the string for "hi", and then you would use find() to search the string for "my". Of course that would also identify strings that have "my" first followed by "hi". If you only want strings with "hi" followed by "my", then when you search for "my" start searching the string from the location of "hi" to the end of the string rather than searching the whole string.