Skip to content

Instantly share code, notes, and snippets.

@cpq
Created September 7, 2019 14:25
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 cpq/e972c88872f77793dbf8ddb4445743a1 to your computer and use it in GitHub Desktop.
Save cpq/e972c88872f77793dbf8ddb4445743a1 to your computer and use it in GitHub Desktop.
Print singly linked list in reverse order
#include <stdio.h>
struct entry {
int value;
struct entry *next;
};
static void out(struct entry *e) {
if (e->next != NULL) out(e->next);
printf("%d\n", e->value);
}
int main(void) {
struct entry a = {1, NULL}, b = {2, &a}, c = {3, &b}, *head = &c;
out(head);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment