You do not highlight the first dimension, i.e. a is a null pointer when you try to dereference it.
BTW, sizeof(int) not enough to store two numbers.
Here is the whole correct code (although not perfect if a is a global global variable):
int (*a)[2] = NULL; void getData(void) { FILE *fp = fopen("input.txt", "r"); int number; fscanf(fp, "%d", &number); a = malloc(number * sizeof *a); for (int i = 0; i < number; i++) fscanf(fp, "%d %d", &a[i][0], &a[i][1]); fclose(fp); }
source share