title: how to convert a 2d array which is globally available to a malloc array(which can be passed as a parameter)
body: <p>I want to change my globally available 2d array to a malloc array and pass it to the following function</p>
  
  <p>I have this 2d array as a global variable</p>
  
  <pre><code>char grid[ROW][COLUMN];
  </code></pre>
  
  <p>I want to pass it to this functionas a parameter, but using a malloc array</p>
  
  <pre><code>void draw_grid(int row, int col) 
  {
  
  
       printf(" ");
      for (int c = 0; c &lt; col; ++c) 
      {
          printf(" ");
          printf(" %d", c);
       //   printf(" ");
  }
  
         printf("\n");
  
  
      for (int r = 0; r &lt; row; ++r) 
      {    
  
          printf("%d", r);
          printf("|");
  
          for(int dot = 0; dot &lt; (row*col); ++dot) 
          {
              grid[r][dot] = ' ';                        
  
  
              printf("|");
              printf("%c", grid[r][dot]);
  
              printf(" ");
  
              // Dots needs to remain within the grids bounds
              if (dot == (col) - 1) 
              {
                  printf("|| \n");
                  //printf("\n");
                  break;
              }
          }
  
      }
  
  }
  </code></pre>