View Single Post
  #1  
Old 11-12-2007, 05:31 PM
DeadlyGambit DeadlyGambit is offline
Senior Member
 
Join Date: Jul 2005
Posts: 122
Default PLEASE Help Me With Simple C++ Code!

Okay I have to search a large text file for instances of a user-entered string. I did this using the find function, and it works properly. Here is the problem, I can only find the FIRST occurance of the specified string within any giving line. (I'm searching line by line here, using getline to read lines from the file, and then using find function to find string.) But I need to find ALL instances of the specified string within each line. As of now, it just stops when it finds the first instance within each line.

Example (this is actually the 1st line of text in the file):
Say the search phrase is "hate me "

"5 meg file hate me hate me hate men gg hate merry"

this would result in "hate me" being counted 4 times on that line
("hate me " only twice)
Reply With Quote