title: C Default initialization of nested structures
body: <p>I had been trying to initialize a nested structure with default values, and assign only specific fields of the sub-sub structure fields. So that I don't have to initialize all contents of the nested structures.</p>
  
  <p>As you can see from the sample code below, it generates a segmentation fault while trying to print the field values of sub-sub-structure. Does anyone suggest a better way of initializing default value without going through each field?
  Thanks</p>
  
  <pre><code>struct special_char
  {
      char c;
      int size;
  };
  
  struct alphabet
  {
      struct special_char* special_c;
      int special_char_size;
  };
  
  struct numeral
  {
      int array_numeral;
      int size;
  };
  struct alpha_numeral
  {
      struct alphabet alpha;
      struct numeral num;
      int size;
  };
  
  int main()
  {
      printf(" Initialization of nested structures !\n");
      struct alpha_numeral test = { { { 0 } } };
      printf("values %d", test.alpha.special_c-&gt;size);
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>Output: Initialization of nested structures !<br>
    Segmentation fault (core dumped)</p>
  </blockquote>