You changed from double to int, presumably to simplify things during testing, but now this is wrong:
Code:
data[h] = (int*) malloc(3*sizeof(double));
You could have avoided this problem by writing:
Code:
data = malloc(330770 * sizeof(data[0]));
for (int h = 0; h < 330770; h++) {
data[h] = malloc(3 * sizeof(data[0][0]));
}
By the way, since you have a rectangular 2D array for which the inner arrays are of fixed size, this might be better:
Code:
int (*data)[3] = malloc(330770 * sizeof(data[0]));
/* no need to allocate for each inner array */
EDIT:
Also, I strongly suggest that you use const or #define to give a name to 330770. It is just too magical.
EDIT #2:
Oh, and this is wrong:
Code:
while(fscanf(fr,"%d", &data[x][y++]) >0);
You should be checking that the number of times this loop runs is exactly 3.