title: malloc causes segmentation fault in C
body: <p>I am setting a pointer to pointers like in the code above. The problem is that malloc is throwing a segmentation fault no matter what I have tried. Here is the code: </p>
  
  <pre><code>wchar_t **Words ;
  int lc = lineCounter() ;
  **Words = malloc( lc * sizeof(int)  ) ;
  if (**Words == NULL) return -1 ;
  </code></pre>
  
  <p>The lineCounter function is just a function that returns the number of lines in a file.
  So what I try to do is free some memory that is needed to save the pointers to lc number of words. </p>
  
  <p>Here is a visual representation of what I have in mind : </p>
  
  <p><img src="https://i.stack.imgur.com/v3ElB.jpg" alt="enter image description here"></p>