title: Additional variable in struct causes wrong return value in getter method
body: <p>I'm very new to programming in C, but I have been using Java for years. I created a struct with two variables and a getter method (DFA_get_size) to return the value of one. However, when I added a third variable (the one commented out) the function DFA_get_size began to return the wrong number. I don't understand why this is happening. Please help.</p>
  
  <p>Below is the entire program.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  
  typedef struct DFA {
      int nstates;
      //int trans;
      int ai;
  } DFA;
  
  extern DFA DFA_new(int nstates){
      DFA dfa;
      dfa.nstates = nstates; 
      dfa.ai = 0;
  }
  
  extern int DFA_get_size(DFA dfa){
      return dfa.nstates; 
  }
  
  int main(){
      DFA test = DFA_new(8);
      printf("%d\n", DFA_get_size(test));
  }
  </code></pre>