Read from file into 2d array

I am a late joiner into a CSC 250 course and thus missed the first few weeks of class. I am scrambling in the transition from C to C++, specifically reading information from a .txt file. In C, using fscanf in a simple while loop would read the first integer and automatically move on to the next, but no matter what kind of loop I use to read numbers from a file in C++ it only ever reads the first number.

Specifically I am trying to take a .txt of integers and place them into a 2D array. I have nested For loops prepared to store the data, but I simply don't know how to get it from the file one at a time. I looked through this site and the most help I could find was using getline from myfile and turning the string into a stream, but it only ever reads the first piece of data.

I'm incredibly overwhelmed, literally learning a new language overnight, and would love a little help in this. Thank you.
Formatted input operators
http://www.cplusplus.com/reference/istream/istream/operator>>/

If this doesn't work post the code.
Last edited on
Topic archived. No new replies allowed.