Created
October 23, 2008 04:34
-
-
Save bastos/18919 to your computer and use it in GitHub Desktop.
LinkedList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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