title: Allocating memory dynamically to a 2-d array of strings
body: <pre><code>int ReadNames(char ***Names, int *r,int *c)    
  {
  int i, j, k;
  char name[100];
  printf("Number of Rows: ");
  scanf("%d", r);
  
  printf("Number of Columns: ");
  scanf("%d", c);
  
  Names=(char ***)malloc(sizeof(char **)*(*r));
  for(i=0;i&lt;(*r);i++)
  *(Names+i)=(char **)malloc(sizeof(char *)*(*c));
  
  for(i=0;i&lt;(*r);i++)
  for(j=0;j&lt;(*c);j++)
  {
  fflush(stdin);
  gets(name);
  strcpy(*(*(Names+i)+j),name);
  }
  return 1;
  }
  </code></pre>
  
  <p>I am trying to allocate the memory to a 2-D array of strings. Later on i want to sort them row wise and column wise, but while allocating the memory , the program is not responding. Is there something i am doing in my code.</p>
  
  <p>in main function readname is called as  </p>
  
  <pre><code>    ReadNames(&amp;p,&amp;r,&amp;c)
  </code></pre>
  
  <p>where r and c are the no. of rows and columns.</p>