title: Reversing a singly linked list in C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1801549/reverse-a-singly-linked-list">How to reverse a singly linked list using only two pointers?</a>  </p>
  </blockquote>
  
  
  
  <p>This is C code to reverse a linked list. But this isn't producing the desired output.</p>
  
  <pre><code>struct node *temp,*prev;
  while(head-&gt;next!=NULL)
    {
      temp=prev=head;
      while(temp-&gt;next-&gt;next!=NULL)
        {
      temp=temp-&gt;next;
      prev=prev-&gt;next;
        }
      temp=temp-&gt;next;
      temp-&gt;next=prev;
      prev-&gt;next=NULL;
    }
  </code></pre>
  
  <p>What am I missing?</p>