title: dynamic strings in struct
body: <p>I am having a problem with understanding the concept of dynamic memory allocation, I have some code that is encountering a segfault perhaps some one may have some insight?</p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
  
  
  typedef struct tName
  {
     char **stringA;
     int capacity;
  } tName;
  
  tName *createTName(int length);
  tName *destroyTName(tName *l);
  
  int main(void) {
      tName *ll = createTName(10);
  }
  
  tName *createTName(int length) {
      tName *temp;
      int i;
      temp-&gt;capacity = length;
  
      temp-&gt;stringA= (char**) malloc(sizeof(char*) * length);
      for(i=0;i&lt;length;i++)
         temp-&gt;stringA[i] = (char*) malloc(sizeof(char)*50);
  
      return temp;
  }
  </code></pre>
  
  <p>When I call run this program I get a segfault, can anyone assist me please?</p>