title: Unable to create stack with proper node
body: <p>This is the initial part of main function I used:</p>
  
  <pre><code>int main() {
  int q;
  struct ListNode* S = NULL;
  scanf("%d\n",&amp;q);
  int i;
  for (i=0;i&lt;q;i++){
      int queryType;
      scanf("%d", &amp;queryType);
      struct NumOp* j;
      struct NumOp k;
      if(queryType == 1){
          double num;
          scanf("%lf", &amp;num);
          if(num&gt;=1 &amp;&amp; num&lt;=100){
              k.type='n';
              k.num=num;
              k.op='\0';
              j=&amp;k;
              Push(&amp;S,j);
          }
      }
  </code></pre>
  
  <p>Now the issue is this would create a stack consisting of the last pushed element in all the nodes pushed by this time.
  On making certain changes the following code seemed to work fine. Could anyone tell me why this didn't work in first place.</p>
  
  <pre><code>int main() {
  int q;
  struct ListNode* S = NULL;
  scanf("%d\n",&amp;q);
  int i;
  for (i=0;i&lt;q;i++){
      int queryType;
      scanf("%d", &amp;queryType);
      struct NumOp* j = (struct NumOp*) malloc(sizeof(struct NumOp));
      if(queryType == 1){
          double num;
          scanf("%lf", &amp;num);
          if(num&gt;=1 &amp;&amp; num&lt;=100){
              j-&gt;type='n';
              j-&gt;num=num;
              j-&gt;op='\0';
              Push(&amp;S,j);
          }
  </code></pre>
  
  <p>The explanation is what I m looking for.</p>