- #1
NDiggity
- 54
- 0
Homework Statement
The program is to read in a file full of numbers formatted like this: The first line contains a single int n. Following this line, there will be n lines with n ints each separated by whitespace.
So I have asked the user for a file path and read in the first number ('n') which tells me how big the array I need to make should be, and created a dynamically allocated 2d array with the dimensions nxn which is what we are supposed to do.
Then, I need to make a copy of this file into the dynamically allocated array. Then I need to check whether the file contains a magic array, meaning the sum of every row and column is identical, and report to the user where it is.
My problem is making a copy into my 2d array. I'm using fscanf with for loops to read in each value, but that initial int('n') at the top of the file screws it up. Is there any way I can get it to skip this number when it reads this in, because it screws up the contents of the array.
Here is an example of the file I need to copy:
3
1 2 3
3 2 1
2 1 3