Skip to content

Instantly share code, notes, and snippets.

@bastos
Created October 23, 2008 04:34
Show Gist options
  • Save bastos/18919 to your computer and use it in GitHub Desktop.
Save bastos/18919 to your computer and use it in GitHub Desktop.
LinkedList
#include<stdlib.h>
#include<stdio.h>
struct list_el {
int val;
struct list_el *next;
};
typedef struct list_el item;
void 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;
while(curr) {
printf("%d\n", curr->val);
curr = curr->next ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment