dynamically initialize a 3D character array in c : <p>I am trying to initialize a 3D character array, but couldn't. when i execute the program crashes. 
    I need to store 'T' sets of 'N[i]' no.of words in the ***word.characters in each word are less than 20.
"The program executes when static initialized." </p>

<pre><code>#include&lt;stdio.h&gt;
#include&lt;stdlib.h&gt;
#include&lt;conio.h&gt;
#include&lt;string.h&gt;
#include&lt;math.h&gt;

int main()
{
int i,j,k,T,sum=0;
printf("\nEnter the no of test cases");
scanf("%d",&amp;T);

int *N;
N=(int*)malloc(T*sizeof(int));

int **t;
t=(int**)malloc(T*sizeof(int*));
for(i=0;i&lt;T;i++)
{
    t[T]=(int*)malloc(N[i]*sizeof(int));
}

char ***word;
word = (char ***)malloc(T*sizeof(char**));
        for (i = 0; i&lt; T; i++)
        {
             word[T] = (char **) malloc(N[i]*sizeof(char *));
          for (j = 0; j &lt; N[i]; j++) {
              word[T][N[i]] = (char *)malloc(20*sizeof(char));
          }
        }
</code></pre>
