Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created July 23, 2016 13:08
Show Gist options
  • Select an option

  • Save wohhie/5bbd64d0772821c6da97c3f86e54d784 to your computer and use it in GitHub Desktop.

Select an option

Save wohhie/5bbd64d0772821c6da97c3f86e54d784 to your computer and use it in GitHub Desktop.
//LinkedList Insert & display
//LinkedList code
//insert and display list
#include <stdio.h>
#include <cstdlib>
struct Node {
int val;
struct Node *next;
};
typedef struct Node item;
int main() {
item *curr, *head;
int i;
head = NULL;
for (i = 1; i < 10; i++) {
curr = (item *)malloc(sizeof(item));
curr->val = i;
curr->next = head;
head = curr;
}
curr = head;
printf("\n");
while (curr) {
printf("%d->", curr->val);
curr = curr->next;
}
printf("NULL");
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment