So basically I am trying to read from a huge text file and need to store the data in a 2D string array in C. But I am getting a segmentation fault every time.
Here is the code I use to create the array:
Y = 3
X = 12
char ***some_array=NULL;
some_array = (char ***)malloc(Y * sizeof(char *));
for (int i=0; i<Y; i++)
for (int j=0; j<X; j++){
some_array[i] = (char **)malloc(X * sizeof(char *));
some_array[i][j] = (char *)malloc(16 * sizeof(char));
}
So technically, I am creating a 3D char array for this means. Am I doing something wrong here?