title: seg fault at the end of program after executing everything?
body: <p>I wrote a quick program which executes every statement before giving a seg fault error.</p>
  
  <pre><code>struct foo
  {
      int cat;
      int * dog;
  };
  
  void bar (void * arg)
  {
      printf("o hello bar\n");
      struct foo * food = (struct foo *) arg;
      printf("cat meows %i\n", food-&gt;cat);
      printf("dog barks %i\n", *(food-&gt;dog));
  }
  void main()
  {
      int cat = 4;
      int * dog;
      dog = &amp;cat;
  
      printf("cat meows %i\n", cat);
      printf("dog barks %i\n", *dog);
  
      struct foo * food;
      food-&gt;cat = cat;
      food-&gt;dog = dog;
  
      printf("cat meows %i\n", food-&gt;cat);
      printf("dog barks %i\n", *(food-&gt;dog));
  
      printf("time for foo!\n");
      bar(food);
      printf("begone!\n");
  
      cat = 5;
      printf("cat meows %i\n", cat);
      printf("dog barks %i\n", *dog);
  
  //  return 0;
  }
  </code></pre>
  
  <p>which gives a result of</p>
  
  <pre><code>cat meows 4
  dog barks 4
  cat meows 4
  dog barks 4
  time for foo!
  o hello bar
  cat meows 4
  dog barks 4
  begone!
  cat meows 5
  dog barks 5
  Segmentation fault (core dumped)
  </code></pre>
  
  <p>I'm not really sure why it seg faults at the end? Any comments/insights are deeply appreciated. </p>