I have a text file with on every line one or more integers, seperated by a space. How can I in an elegant way read this with C++? If I would not care about the lines I could use cin >>, but it matters on which line integers are.
Example input:
1213 153 15 155
84 866 89 48
12
12 12 58
12
It depends on whether you want to do it in a line by line basis or as a full set. For the whole file into a vector of integers:
If you want to deal in a line per line basis: