title: C updating an array index that is a struct member also updates all previous indexes
body: <p>I have a struct as follows:</p>
  
  <pre><code>struct Stack {
  int top;
  struct Token data[size]};
  };
  </code></pre>
  
  <p>And the following push Method:</p>
  
  <pre><code>void push(struct Stack *st, struct Token tok) {
  (*st).top++;
  (*st).data[(*st).top] = tok;
  }
  </code></pre>
  
  <p>Every time I call the push method on a struct Stack s, it updates the whole array s.data (until index top) with the new value <strong>instead of only</strong> the specified index data[top]. Any ideas why this is happening? </p>
  
  <pre><code>struct Stack stack1;
      stack1.top = -1;
  
      readNext();
      //currentToken.value == "class"
      push(&amp;stack1,currentToken);
  
      readNext();
      //currentToken.value == "test"
      push(&amp;stack1,currentToken);
  
      readNext();
      //currentToken.value == "{"
      push(&amp;stack1,currentToken);
  
      readNext();
      //currentToken.value == "int"
      push(&amp;stack1,currentToken);
  
      printStack(stack1);
  </code></pre>
  
  <p>output is:</p>
  
  <pre><code>int
  int
  int
  int
  </code></pre>