title: Adding a node to a linked list stack in C
body: <p>So I've got this code already: <a href="http://pastebin.com/3wuFNWGA" rel="nofollow">http://pastebin.com/3wuFNWGA</a></p>
  
  <p>And I've got these typedefs in a .h file: <a href="http://pastebin.com/JTG9XHvW" rel="nofollow">http://pastebin.com/JTG9XHvW</a></p>
  
  <p>I need my push function to add a node to my_stack by allocating memory for the node, storing the data (new element) in the node, and inserting the node at the top of the stack. The code runs but when I try to print the value in my_stack->top->data after pushing a new value onto the stack, it always prints zero and not the element I supposedly pushed onto the stack.</p>
  
  <p>For the life of me, I can't figure out why. I don't think there's a problem arising when I create the new node and store the value in data so I'm thinking there's a problem when I try to make my_stack->top point to the most recently added node?</p>
  
  <p>This is also my first post on Stack Overflow.  I hope I did everything right.</p>
  
  <p>Here's the push function to push a value onto the stack:</p>
  
  <pre><code>void push( Stack *my_stack, int newElement ) {
      Node_s *newNode;
      newNode = (Node_s *) malloc(sizeof(Node_s));
      if( newNode == NULL ) {
              printf("Error: malloc failed in push\n");
              exit(EXIT_FAILURE);
      }
      newNode-&gt;data = newElement;
      newNode-&gt;next = my_stack-&gt;top;
      my_stack-&gt;top = newNode;
  }
  </code></pre>