title: Dynamically allocate a string matrix in C
body: <p>I'm trying to read a map from a text file and create a string array according to the number of rows and columns in the map. Every cell in the grid is a 2 character string.</p>
  
  <p>For instance, </p>
  
  <pre><code>**--**--**--
  --**--**--**
  </code></pre>
  
  <p>should create a 2*6 matrix. The number of rows and columns are ROWS and COLS respectively. I used</p>
  
  <pre><code>char ***map = malloc(ROWS * sizeof(char *));
  for (i = 0; i &lt; ROWS; i++) 
  {
      map[i] = malloc(COLS * sizeof(char) *  2);
  }
  </code></pre>
  
  <p>But when I try to use a <code>map[x][y]</code>, it will segfault.</p>