title: Printing linked list always prints last node
body: <p>I am currently  working on a project in which I need to add a Node at the end of a linked list (which should be easy nut is driving me nuts). The problem is that when I try to print the full linked list I get the data of the last node repeatedly.
  My code:</p>
  <pre><code>struct page *add_page (struct page *web, char *url){
      struct page *newNode = (struct page*) malloc(1*sizeof(struct page));
      newNode-&gt;url = url;
      newNode-&gt;next = NULL;
      
      if(web == NULL){
          web = newNode;
      }else{
          struct page *curr = web;
          while(curr-&gt;next != NULL){
              if(newNode-&gt;url==curr-&gt;url){
                  printf(&quot;URL \&quot;%s\&quot; is already on the web\n&quot;,newNode-&gt;url);
                  return web;
                  free(newNode);
              }else{
                  curr = curr-&gt;next;
              }
          }
          curr-&gt;next = newNode;
      }
      return web;
      free(newNode);
  }
  </code></pre>
  <p>I am sure that the problem is on this function. I have tried other ways but this is the best I could get.
  Thanks in advance.</p>