Searching a text file.

I've got a C++ final project due in ~19 hours and have completed all the requirements for it aside from having a working search function and recall function.

My project is a dice roller that allows the user to specify the number of faces on each die, and the number of dice to roll. It then outputs to the console, and to a log file a timestamp, the number of faces on each die, the number of dice rolled, then the results on each die (not summed).

For the recall, I just want to allow the user to read the contents of the logfile from within the program (this is actually likely quite easily accomplished using read()).

The search looks to be a bit more complicated, though. I want the user to be able to enter an integer to search for, then have it return the number of occurrences of the number the user searched for (something like STL's count()). There is a catch, though, I want it to exclude the timestamp, facecount, and number of dice rolled from the search. Since these will repeat (I have it set to append the log file, not overwrite it), the function needs to be robust enough to exclude them each time it encounters them.

My stress level is high and I'm having trouble coming up with ideas. Any assistance would be greatly appreciated.
You should create a class that represents an entry in the file and then read the file line by line into these structures. The rest should be simple.
Topic archived. No new replies allowed.