-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNode.c
More file actions
28 lines (25 loc) · 737 Bytes
/
Copy pathNode.c
File metadata and controls
28 lines (25 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<stdio.h>
#include<stdlib.h>
//node creation
struct node
{
int data;
struct node *next; //self referential object
};
int main()
{
struct node *newNode;// maked a pointer with a data type of struct node
newNode=(struct node*)malloc(sizeof(struct node));
//above line allocates the 16 bytes and stores the address of this 16 byte in newNode
printf("the size of a single node is %d and newNode pointer is %d \n",sizeof(struct node),sizeof(*newNode));
if (newNode==NULL)
{
printf("unable to allocate the memory to newNode!");
exit(1);
}
printf("enter the data : ");
scanf("%d",&newNode->data);
printf("the data in node is %d ",newNode->data);
newNode->next=NULL;
return 0;
}