Skip to content

Instantly share code, notes, and snippets.

@KushalP
Created March 24, 2010 16:40
Show Gist options
  • Save KushalP/342475 to your computer and use it in GitHub Desktop.
Save KushalP/342475 to your computer and use it in GitHub Desktop.
#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