title: Memory allocation for pointer to array and array of pointer
body: <p>Below is the part of code I am stuck on. I want to dynamically allocate memory for </p>
  
  <ul>
  <li>Pointer to array  </li>
  <li>Array of pointers</li>
  </ul>
  
  <p>I am getting several error messages like invalid conversion from int * to int and so on.</p>
  
  <p><strong>Pointer to array</strong></p>
  
  <pre><code>int (*array)[nrows][ncolumns];
  array = (int*)malloc(nrows * ncolumns * sizeof(int));
  
  
  printf("\n Enter the elements:\n");
  
  for(i=0; i&lt;nrows; i++)
  {
      for(j=0; j&lt;ncolumns; j++)
      {
          scanf("%d", array[i][j]);   
      }
  }
  
  printf("Entered array is :\n\n");
  
  for(i = 0;i&lt;nrows; i++)
  {
      for(j = 0; j&lt;ncolumns; j++)
      {
          if(j== ncolumns-1)
          {
              printf("%d \n", *array[i][j]);
          }
          else
          {
              printf("%d", *array[i][j]);
          }
  </code></pre>
  
  <p><strong>Array of pointers</strong></p>
  
  <pre><code>int *array[nrows][ncolumns];
  array[nrows][ncolumns] = (int*)malloc(nrows * ncolumns * sizeof(int));
  
  printf("Enter elements:\n");
  
  for(i = 0; i&lt;nrows; i++)
  {
      for(j = 0; j&lt;ncolumns;j++)
      {
          scanf("%d",&amp;array[i][j]);
  
  
      }
  }
  
  
  printf("Entered array is: \n");
  for(i = 0; i&lt;nrows; i++)
  {
      for(j = 0; j&lt;ncolumns;j++)
      {
          if(j == ncolumns-1)
          {
              printf("%d \n",array[i][j]);
          }
          else
          {
              printf("%d \t",array[i][j]);
          }
  
  
      }
  }
  </code></pre>