Skip to content

Instantly share code, notes, and snippets.

@amulyagaur
Created July 16, 2017 18:20
Show Gist options
  • Save amulyagaur/274c355115114ddb0ef3ea7a2f1bc15b to your computer and use it in GitHub Desktop.
Save amulyagaur/274c355115114ddb0ef3ea7a2f1bc15b to your computer and use it in GitHub Desktop.
//function to insert a new node at the head of the list
node* InsertAtHead(node* head,int x)
{
node* temp = new node(); //dynamically allocate a new node
temp->data =x; //sets the data part to the required value
temp->next=head; //sets the link part
head =temp;
return head; //returns the head pointer to calling function ie.main()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment