find specific line in txt file.

...
Last edited on
You could read into a std::string type and then use the find algorithm to locate the date's entry position.

ref: http://www.cplusplus.com/reference/algorithm/find/?kw=find
Last edited on
Since the date field is at the beginning of each line, you could read each line in turn, get the date which is line.substr(0,10) and test if it is equal to the user input date.
http://www.cplusplus.com/reference/string/string/substr/

To read a file line by line, see the second example in the tutorial under the heading, Text files
http://www.cplusplus.com/doc/tutorial/files/
Topic archived. No new replies allowed.