Read from txt into 2D array

gem_max

Member
Joined
Aug 28, 2006
Messages
5
Programming Experience
Beginner
Hello I need this txt file:

4 7 6 9 3 1 8 5 2
9 1 5 8 2 6 7 4 3
8 2 3 4 7 5 9 6 1
2 9 1 7 5 3 4 8 6
5 8 7 1 6 4 3 2 9
6 3 4 2 9 8 5 1 7
7 4 8 6 1 9 2 3 5
1 5 9 3 8 2 6 7 4
3 6 2 5 4 7 1 9 8

...to be read into a 2d array. All my attempts using read, readline, readtoend have all failed somehow and often just when I think I've got it the debug process runs but never ends...

From that data alone could someone please give me an example of how to load such information into a 2d integer array? I think loops are my issue but I can't find any 2d examples to base the structure off.
 
wait wait it works now. Got someone else to look at my loops and they spotted where to add the reset to 0 line. PHEW!
 
Back
Top