Skip to content

Instantly share code, notes, and snippets.

@ben-ng
Created March 4, 2019 06:06
Show Gist options
  • Save ben-ng/33a6de83c71046fca6a03fcc749a471b to your computer and use it in GitHub Desktop.
Save ben-ng/33a6de83c71046fca6a03fcc749a471b to your computer and use it in GitHub Desktop.
Reverse a linked list in C
while (current != null) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
head = prev;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment