Created
August 18, 2019 20:21
-
-
Save tanaytoshniwal/a6b0d68b3542c019e3087b8897c8b063 to your computer and use it in GitHub Desktop.
Linked List Insert Function
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
Node* insert(Node* head, int data){ | |
Node *node = (struct Node*)malloc(sizeof(struct Node*)); | |
node->data = data; | |
node->next = NULL; | |
if(head == NULL){ | |
head = node; | |
return head; | |
} | |
Node* temp = head; | |
while(temp->next!=NULL){ | |
temp = temp->next; | |
} | |
temp->next = node; | |
return head; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment