title: How to delete node from doubly linked list in c
body: <p>I am working on doubly linked list in c, I have a doubly linked tepm2 with 20 nodes and I want to delete the node whose word user insert.</p>
  
  <pre><code>struct node {
      struct node *prev;
      char word[100];
      int repeatTime;
      struct node *next;
  } *h, *temp, *temp1, *temp2;
  </code></pre>
  
  <p>Each node has unique word.</p>
  
  <pre><code>printf("\n Enter word to delete  : ");
  scanf("%s", &amp;word);
  Delete(word);
  
  int delete(char data[200]) {      //unable to delete
      if (h == NULL)
          return;
  
      temp2 = next = previous = h;
  
      while (temp2-&gt;next != NULL) {
          if ((strcmp(temp2-&gt;word, data) == 0)) {
              if (temp2-&gt;prev == NULL) {
                  h = temp2-&gt;next;
                  free(temp2);
                  return;
              } else if (temp2-&gt;prev == NULL) {
                  previous-&gt;next = temp2;
                  free(temp2);
                  previous-&gt;next = NULL;
                  return;
              } else {
                  previous-&gt;next = temp2-&gt;next;
                  next-&gt;prev = temp2-&gt;next;
              }
          }
  
          temp2 = temp-&gt;next;
      }
  }
  </code></pre>
  
  <p>I am been unable to delete the specific node that word user enter</p>