a link list code question..
Code:
#include<stdlib.h>
#include<stdio.h>
struct list_el { //type list_el
int val;
struct list_el * next;
};
typedef struct list_el item; //item is alias for list_el
void main() {
item * curr, * head;
int i;
head = NULL; //head is an item with two variables
//does it put null on every sub variable of head??
for(i=1;i<=10;i++) {
curr = (item *)malloc(sizeof(item));
curr->val = i;
curr->next = head; //*(curr).next is a value, head is an address of a pointer
//putting one into another makes no sense??
head = curr;
}
curr = head;
while(curr) {
printf("%d\n", curr->val);
curr = curr->next ;
}
}