Advertisement
afrinahoque

Hoynaa:3

Dec 13th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. void delete_by_name()
  2. {
  3.     node *temp;
  4.     node *list=head;
  5.     {
  6.         char x;
  7.         printf("Enter the Book Name:\n");
  8.         scanf(" %[^\n]", x);
  9.  
  10.         if(head==NULL)
  11.         {
  12.             printf("There's Nothing Still.\n");
  13.         }
  14.         else
  15.         {
  16.         if(head->b==x)
  17.         {
  18.             temp=head;
  19.             head=temp->next;
  20.             free(temp);
  21.         }
  22.         else if(tail->b==x)
  23.         {
  24.             temp=tail;
  25.             temp->prev->next=NULL;
  26.             tail=temp->prev;
  27.             free(temp);
  28.         }
  29.         else
  30.         {
  31.             while(list->next->b!=x && list->next->next!=NULL)
  32.             {
  33.                 list=list->next;
  34.             }
  35.             temp=list->next;
  36.             temp->prev->next=temp->next;
  37.             temp->next->prev=temp->prev;
  38.             free(temp);
  39.         }
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement