Created
March 24, 2010 16:40
-
-
Save KushalP/342475 to your computer and use it in GitHub Desktop.
This file contains 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_element | |
{ | |
int val; | |
struct list_element *next; | |
}; | |
typedef struct list_element 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