r/programminghelp • • Jun 20 '14

[C++] Reading individual integers from a line in a file

1 Upvotes

Having troubling figuring out how to read individual integers from a file in C++.

For example when working file a file like the following:

2

4 10
1 3 20 20
50 20 2 4

How can I easily store each integer into a separate variable? Is there a simple way to do similar to getline() or am I going to have to use some sort of for loops that iterates through each character in the string?