I have to assign memory to a 3D array using a triple pointer.
#include
int main()
{
int m=10,n=20,p=30;
char ***z;
z = (char***)
To completely allocate a 3D dynamic array you need to do something like the following:
#include
#include
int main()
{
int m=10,n=20,p=30;
char ***z;
z = malloc(m * sizeof(char **));
assert(z != NULL);
for (i = 0; i < m; ++i)
{
z[i] = malloc(n * sizeof(char *));
assert(z[i] != NULL);
for (j = 0; j < n; ++j)
{
z[i][j] = malloc(p);
assert(z[i][j] != NULL);
}
}
return 0;
}
Freeing the data is left as an exercise for the reader.