I would like to ask why is that giving me seg fault. int **a = (int**) malloc (sizeof(int*) * 3); a[0][1] = 1; a[0][1] = 2; a[0][2] = 3; for(int i = 0; i < 3; i++) { printf("%d", a[0][i]); //but works with for instance: a[0][1] }