I know how to read a file into a 2d array using for loops to direct where you are storing the data in C, but what I am interested in is if you can use one fread() call to do this. That is, can I do something like this:
int A[5][5];
fread(&A, sizeof(int), 25, filePtr);
I am getting seg faults when I tried this so right now so I am wonder if this can be done at all.
EDIT: Alright, I guess using fread this way isn't really my problem. My problem is that I have to call fread from within a function and A is defined outside of that function.
func(int size, int ***A)
{
fread(*A, sizeof(int), size*size, filePtr);
}
main
{
int A[n][n];
func(n, &A);
}
So my problem is that my call to fread still seg faults and I HAVE to use a triple pointer for my function prototype. I tried just A (instead of *A) for fun but still got the same seg fault. It looks like I'm just overlooking something with pointers.