Skip to content

Instantly share code, notes, and snippets.

@irrationnelle
Created November 4, 2015 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irrationnelle/8eac6ce09883a0ce16f6 to your computer and use it in GitHub Desktop.
Save irrationnelle/8eac6ce09883a0ce16f6 to your computer and use it in GitHub Desktop.
I did not declare and substitude NewHead, I just made 'NewHead->NextNode' point former Head's tail node.
void SLL_InsertHead(Node** Head, Node* NewHead)
{
if((*Head) == NULL)
*Head = NewHead;
else
{
NewHead->NextNode = (*Head)->NextNode;
*Head = NULL;
}
}
@irrationnelle
Copy link
Author

void SLL_InsertHead(Node** Head, Node* NewHead)
{
  if((*Head) == NULL)
    *Head = NewHead;
  else
  {
    NewHead->NextNode = (*Head)->NextNode;
    *Head = NewHead;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment