title: malloc of matrix of struct - C
body: <p>I'm working on a game project. One of my struct contains a matrix of another struct. I  can't manage to get the malloc works. Here is my actual code :</p>
  
  <pre><code>m-&gt;tiles = malloc(sizeof(struct *tile)*width);
  
  for (i=0; i&lt;width ; i++){
      m-&gt;tiles[i] = malloc(sizeof(struct tile)*height);
  }
  </code></pre>
  
  <p>And I got this error message : </p>
  
  <pre><code> map.c:111:37: error: expected ‘{’ before ‘*’ token
   m-&gt;tiles = malloc(sizeof(struct *tile)*width);
  </code></pre>
  
  <p>I never did it before. Already allocate memory for int matrix but never struct matrix. </p>
  
  <p>Thank you. </p>
  
  <p>EDIT : Thank you BLUEPIXY your answer works. But I think I didn't well defined my struct :</p>
  
  <pre><code>struct map{
  
     int map_width;  // Nombre de tiles en largeur
     int map_height; // Nombre de tiles en hauteur
  
     struct tile **tiles; // ensemble des tiles de la map
  };
  </code></pre>
  
  <p>It should be "struct tile ***tiles" ? </p>