Code:

#include <stdio.h>
#include <stdlib.h>
int ***get(const int N, const int M, const int K);
void fillArray(int*** array, const int N, const int M, const int K);
void printArray(int*** array, const int N, const int M, const int K);
void _free(int ***array, const int N, const int M);
int main(void)
{
int ***array;
int n = 2;
int m = 3;
int k = 2;
array = get(n, m, k);
fillArray(array, n, m, k);
printArray(array, n, m, k);
_free(array, n, m);
return 0;
}
int ***get(const int N, const int M, const int K) /* Malloc the array */
{
int i, j,***array;
array=malloc(N*sizeof(int **));
if ( array == NULL )
{
printf("Can not allocate memory. Exiting ...\n");
exit (0);
}
for(i=0 ; i<N ; i++)
{
array[i]=malloc( M*sizeof(int*) );
if ( array[i] == NULL )
{
printf("Can not allocate memory. Exiting ...\n");
exit (0);
}
for( j = 0 ; j < M ; j++ )
{
array[i][j] = malloc( K*sizeof(int) );
if ( array[i][j] == NULL )
{
printf("Can not allocate memory. Exiting ...\n");
exit (0);
}
}
}
return array;
}
void fillArray(int*** array, const int N, const int M, const int K)
{
int i, j, k;
for( i = 0 ; i < N ; i++ )
{
for( j = 0 ; j < M ; j++ )
{
for( k = 0 ; k < K ; k++ )
{
array[i][j][k] = k;
}
}
}
}
void printArray(int*** array, const int N, const int M, const int K)
{
int i, j, k;
for( i = 0 ; i < N ; i++ )
{
for( j = 0 ; j < M ; j++ )
{
for( k = 0 ; k < K ; k++ )
{
printf("array[%d][%d][%d] = %d\n", i, j, k, array[i][j][k]);
}
}
printf("\n");
}
}
void _free(int ***array, const int N, const int M)
{
int i, j;
for(i = 0 ; i < N ; i++)
{
for(j = 0 ; j < M ; j++)
{
free(array[i][j]);
}
free(array[i]);
}
free(array);
}

Hope that this code will help people