This is my first link list program in C, I am trying to initialize the values of the nodes and trying to print it. however, its not giving me the intended output. Can anyone let me know where am I going wrong?
#include<stdio.h> #include<stdlib.h> struct node { int key; struct node *next; }; typedef struct node NODE; int main () { NODE a,b,c; NODE *list; list=&a; list->key = 10; list->next = &b; list->next->key=20; list->next->next=&c; list->next->next->key=30; list->next->next->next=NULL; printf("%d %d %d", a,b,c); return 0; } It prints 10 and 20 with some garbage in between.
struct node *nextpointer, and probably some padding bits