Created
July 29, 2019 19:40
-
-
Save devansh42/f04d49521d0183151c313156382f1595 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void push_list(LinkedList* list, int value){ | |
Node* n; | |
n=(Node*)malloc(sizeof(Node)); //intializing new node | |
n->value=value; //setting value of new node | |
if(!list->tail){ | |
//It means we are pushing our first node, so intially header and tail node will be same | |
list->head=n; | |
list->tail=n; | |
} | |
//As tail points to the last element of the list, we will set new node as next element of tail element | |
list->tail->next=n; | |
list->tail=n; //As from the above statement n is our new tail, we set new node as tail of list | |
list->length++; // Increasing length of list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment