title: Arrays inside structures
body: <p>So I created a struct whose only element is a pointer to an array.  When I initialize this array, I get a segmentation fault.  Can you tell me why?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>typedef struct {
      int *data;
  } A;
  
  /* Class definition */
  class C {
      A* a;
  public:
      C(void);
  };
  
  /* Constructor */
  C::C(void) {
      a-&gt;data = new int[10];
  }
  
  int main(void) {
      C();
  }
  </code></pre>
  
  <p>Thank you!</p>