Untitled
unknown
plain_text
10 months ago
1.1 kB
30
Indexable
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
int main()
{
struct Node* head = NULL;
struct Node* second = NULL;
struct Node* third = NULL;
head = (struct Node*)malloc(sizeof(struct Node));
second = (struct Node*)malloc(sizeof(struct Node));
third = (struct Node*)malloc(sizeof(struct Node));
head->data = 10;
head->next = second;
second->data = 20;
second->next = third;
third->data = 30;
third->next = NULL;
printf("Start = %d\n",head);
printf("Data in Start = %d\n",head->data);
printf("Pointer in first Node = %d\n",head->next);
printf("Second = %d\n",second);
printf("Data in Second Node = %d\n",second->data);
printf("Pointer in Second Node = %d\n",second->next);
printf("Third = %d\n",third);
printf("Data in Third Node = %d\n",third->data);
printf("Pointer in Third Node = %d\n",third->next);
printf("[%d] [%d][%d] [%d][%d] [%d][%d]",head,head->data,head->next,second->data,second->next,third->data,third->next);
return 0;
}
Editor is loading...
Leave a Comment