Untitled
unknown
plain_text
a year ago
677 B
1
Indexable
Never
#include <stdio.h> #include <stdlib.h> struct node{ int data; struct node *next; }; void printList(struct node* n) { while (n != NULL) { printf(" %d ", n->data); n -> next; } }; int main() { struct node* head =NULL; struct node* second =NULL; struct node* third =NULL; head = malloc(sizeof(struct node )); second = malloc(sizeof(struct node)); third = malloc(sizeof(struct node)); head -> data = 1; head -> next = second; second -> data = 2; second -> next = third; third -> data = 3; third -> next = NULL; printList(head); return 0; }