title: How to allocate memory to a char pointer in a struct in C?
body: <p>I'm using this structure below, but it's limited if I want to get all String from a huge file...</p>
  
  <pre><code>typedef struct arr {
      char name[200]; // Could be a number higher than 200 here...
  } array;
  </code></pre>
  
  <p>Now, if I use...</p>
  
  <pre><code>typedef struct arr {
      char *name;
  } array;
  </code></pre>
  
  <p>Then, is it possible to allocate memory for a char pointer (*name) that is inside a struct (array)?</p>
  
  <p>I don't know what I did wrong, I allocate memory for array, but somehow, I got a Segmentation fault error. The struct with <code>name[200]</code> didn't give me any error. The struct with <code>*name</code> does.</p>
  
  <pre><code>array *str = malloc(sizeof(*str));
  </code></pre>
  
  <p>Did I miss to allocate something else?</p>