Skip to content

Instantly share code, notes, and snippets.

@tanaytoshniwal
Created August 18, 2019 20:21
Show Gist options
  • Save tanaytoshniwal/a6b0d68b3542c019e3087b8897c8b063 to your computer and use it in GitHub Desktop.
Save tanaytoshniwal/a6b0d68b3542c019e3087b8897c8b063 to your computer and use it in GitHub Desktop.
Linked List Insert Function
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