title: Deleting first node in linked list has problems
body: <p>I'm implementing a linked list and it needs to have a function that when given a head of a linked list and a cstring, it finds and deletes a node whose value is the cstring.</p>
  
  <pre><code>typedef struct node
  {
    char entry[21];
    struct node* next;
  } node;
  
  
  /*returns true if node with phrase value found, otherwise false*/
  bool findAndRemove(node* root, char phrase[21])
  {
      if(root != NULL)
      {
          node* previous = NULL;
          while(root-&gt;next != NULL)
          {
              if(strcmp(root-&gt;entry, phrase) == 0)//found
              {
                  if(previous == NULL)//node to delete is at head
                  {
                      node* tmp = root;
                      root = root-&gt;next;
                      free(tmp);
                      return true;
                  }
                  previous-&gt;next = root-&gt;next;
                  free(root);
                  return true;
              }
              previous = root;
              root = root-&gt;next;
          }
          return false;
      }
  }
  </code></pre>
  
  <p>It works alright but when deleting the head some garbage gets printed out. What is happening and how can I fix this? Do I have any memory leaks? Out of curiosity is the term "root" or "head" more commonly used for the first node in a linked list?</p>