Skip to content

Instantly share code, notes, and snippets.

@devansh42
Created July 29, 2019 19:40
Show Gist options
  • Save devansh42/3ce385490750a9342fe3538045e0b568 to your computer and use it in GitHub Desktop.
Save devansh42/3ce385490750a9342fe3538045e0b568 to your computer and use it in GitHub Desktop.
int pop_list(LinkedList* list){
if(!list->head) return -1; //It means, linked list is empty
int value; //holds value of node
value=list->head->value; //accessing node
Node* head; //hold's address of the current header
head=list->head;
list->head=list->head->next; //making new header, the next node to the previous header
free(head); //freeing memory associated with previous header
list->length--;// Decreasing length of linked list
return value; //returning value of poped out node
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment