Based upon the sample input data, the person may have a variable number of names, an age, and then a variable number of scores.
Jessica McKay 45 67 78
Daniel Lun 22 44 54
Mike John Joseph 35 67 45 23 |
Thus it seems that each individual line must be broken into words.
If the word is alphabetic, it is part of the name. If its numeric, it must be
the age. After that, any further numeric values must be scores.
I'd suggest using
getline()
to read each line into a standard C++ string.
Then use a stringstream initialised from that line of text.
The stringstream can be used in the same way as other input streams, to get a word at a time.
I'd put the high-level structure in main() and then call a separate function to handle each line.