*sigh* Malloc get's me every time...
Basically what I'm trying to do is read data from a file to populate a square array on integers.
I'm declaring the array as 'int** matrix' in main(). I pass this to the function which handles reading the file (the parameter for the function is also of type int**).
In that function, I load the data from the file, figure out how large the array has to be and then initiate the array. I do that as follows:
matrix = malloc(size * sizeof(int*));
for (i = 0; i < size; i++)
{
matrix[i] = malloc(size * sizeof(int));
}
I then go ahead and populate the array and print out the results in the function which works fine.
However this doesn't work for some reason. When I try to print the array back in main(), my program is segfaulting.
Any ideas?