I am making a Rubik's Cube that can rotate it's rows and columns. My struct is this:
typedef struct
{
int **cell;
}face;
In this part I am allocating memory for cells. (X is user input)
face faceOne; //There are six of this faces
faceOne.cell = (int **)malloc(x * sizeof(int));
for(int i = 0; i < x; i++)
     faceOne.cell[i] = (int *)malloc(x * sizeof(int));
Then I am filling these cells:
for (int i = 0; i <  x; i++)
  for (int j = 0; j < x; j++)
     {
     faceOne.cell[i][j] = 0;
     printf("%d\n", i);
     }
If x is bigger than 3, program crashes with Segmentation fault. How can i solve this?
 
     
     
    