Link to home
Start Free TrialLog in
Avatar of moevic
moevic

asked on

c++ : search and count how many times a word appears in a file

I need a code snipped to do the following:

Search files: When specifying string to be searched,the program should returns a list of all the files which had
matches within them, as well as the number of matches e.g.
Files containing search string: HELLO
sally.txt: 333
bob.txt: 32
mike.txt: 2

I don't know any method/function that can go word for word in a file, in c++. Something like a java string tokenizer maybe!
ASKER CERTIFIED SOLUTION
Avatar of JackNCalvin
JackNCalvin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mayank S
You mean, you need to implement something similar to the grep command. But you didn't specify whether thw flie-names will be specified by the user or whether it has to search all the files in the directory?

Mayank.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CleanupPing
CleanupPing

moevic:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.