title: Allocating memory for a 2-dimensional array that is in a structure
body: <p>For my project I had to save my data in a dynamic data structure (dynamic array, dynamic list etc..) which size and capacity would be set during execution time with <code>malloc()</code> as I suppose. I completely forgot about it and I was working with that data without allocating any memory.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef struct Bet {
      char* bets[3][2];
  } Bet;
  
  int main() {
       Bet betTypes = { .bets={{&quot;Red&quot;, &quot;Black&quot;}, {&quot;Even&quot;, &quot;Odd&quot;}, {&quot;1 to 18&quot;, &quot;19 to 36&quot;}}};
  }
  </code></pre>
  <p>This is what I am working with. I am confused how should I do this. Do I do</p>
  <pre><code>typedef struct Bet {
      int x;
      int y;
      char* bets[x][y];
  } Bet;
  </code></pre>
  <p>Then in main I create that <code>Bet betTypes;</code> do <code>betTypes.x = 3;</code> and <code>betTypes.y = 2</code> and call <code>malloc()</code> using those x and y? But then how do I create that exact same list of strings, because I didn't find any another ways aside <code>Bet betTypes = { .bets={{&quot;Red&quot;, &quot;Black&quot;}, {&quot;Even&quot;, &quot;Odd&quot;}, {&quot;1 to 18&quot;, &quot;19 to 36&quot;}}};</code>, if I declared <code>Bet betTypes;</code> before that, then the <code>Bet betTypes = { .bets={{&quot;Red&quot;, &quot;Black&quot;}, {&quot;Even&quot;, &quot;Odd&quot;}, {&quot;1 to 18&quot;, &quot;19 to 36&quot;}}};</code> part would not work. Or I suppose I am just too unexperienced with memory allocation and I don't know how this should look like (neither I don't know how to allocate memory for this array)</p>