Skip to content

Instantly share code, notes, and snippets.

@flavio-fernandes
Created May 26, 2018 14:47
Show Gist options
  • Save flavio-fernandes/1102e7441072626709b9f0cfab7f3862 to your computer and use it in GitHub Desktop.
Save flavio-fernandes/1102e7441072626709b9f0cfab7f3862 to your computer and use it in GitHub Desktop.
C Linked List Data Structure Explained with an Example C Program
https://www.thegeekstuff.com/2012/08/c-linked-list-example/
$ diff -u orig.c bug.c
--- orig.c 2018-05-26 14:40:12.495407923 +0000
+++ bug.c 2018-05-26 14:41:03.335407923 +0000
@@ -150,6 +150,10 @@
print_list();
+ add_to_list(666,true);
+ ret = delete_from_list(666);
+ print_list();
+
for(i = 5; i<10; i++)
add_to_list(i,true);
$ diff -u bug.c fix.c
--- bug.c 2018-05-26 14:41:03.335407923 +0000
+++ fix.c 2018-05-26 14:42:51.151407923 +0000
@@ -116,7 +116,7 @@
{
curr = prev;
}
- else if(del == head)
+ if(del == head)
{
head = del->next;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment