Hi,
I am not getting Link List at all. Can anybody help me understand it? I have got an example program which is as follows:
Code:
#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 ;
}
}
And here's the output:
Code:
10
9
8
7
6
5
4
3
2
1
Could you explain me the above program statement-wise? And also explain the notation:
Code:
typedef struct list_el item;
Thanks in advance!