I am writing a c++ prgram and have to read some data from a .txt file.the format looks like the following:
“name gender DD/MM/YYYY HH:MM:SS“
I know how to read a .txt file and cin the words one by one, but i dont know how to deal with the symbols “/” or “:“.
I have to compare the ages of two person.
Please help!
Aside from the easiest way with
sscanf, like Jerry describes, it’s also possible with iostreams. Just read the data you want from the file, until you hit a seperator, and discard that one into a dummychar: