Why print statement doesn't show structure value
This is my code
Code:
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node * next;
};
void ADD ( struct node *Head, int value)
{
struct node * new = malloc( sizeof(*new));
if ( new != NULL )
{
new->data = value;
new->next = NULL;
}
if ( Head == NULL )
{
Head = new;
}
}
int main ()
{
struct node * head = NULL;
ADD(head,2);
printf("%d", head-> data );
return 0;
}
I am expecting this line should print 2 but I don't get any value
Code:
printf("%d", head-> data );