title: Remove duplicate elements from a sorted linked list
body: <p>I am attempting a C program to remove duplicates from a Sorted linked list and i am using a simple concept of traversing the list from the start node. While traversing, compare each node with its next node. If data of next node is same as current node then i delete the next node.</p>
  
  <p>My Code is:</p>
  
  <pre><code>struct node *remove_dup(struct node *start)
  {
      struct node *p,*tmp;
      p=start;
      while(p!=NULL)
      {
          if(p-&gt;info==p-&gt;link-&gt;info)
          {
            tmp=p-&gt;link;  
            p-&gt;link=p-&gt;link-&gt;link;
            free(tmp);
          }
          p=p-&gt;link;
      }
      return start;
  }
  </code></pre>
  
  <p>It is not giving me the correct answer! What is wrong with my execution? Is my concept wrong?</p>