title: Why is the output of this code always the same?
body: <p>Why am I getting the same output in the following for loop in c++.</p>
  
  <pre><code>node* nn =  (struct node*)malloc(sizeof(struct node));      
  for(int i=0;i&lt;10;i++)
  {
  
      node* n =  (struct node*)malloc(sizeof(struct node)); 
      cout&lt;&lt;&amp;n&lt;&lt;endl;
      nn-&gt;next = n;
      nn =n;
  }
  </code></pre>