Does the value of pointer become NULL after freeing it?
int* p = malloc(sizeof(*p));
free(p);
if(p==NULL)
printf("Null\n");
else
printf("Not null\n");
Output:
Not null
Well, I assume not;
Anyway, I have asked a question earlier today :
Check it out here: C - How can I free dynamically allocated memory?
List* head1 = NULL;
insertFront(&head1, 1);
insertFront(&head1, 2);
print(head1);
while (head1)
{
List *temp = head1;
head1 = head1->next;
free(temp);
}
if(head1 == NULL)
printf("Null\n");
else
printf("Not null\n");
Output in this case:
Null
In this case after freeing head1 (nodes also) the head1 becomes null, does'nt it?
And finally, am I missing some concepts?
head1 is null, however p isn't.
My Question is:
Why values differs between head1 and p?