Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *name;
name = (char *) malloc(80*sizeof(char));
if ( name != NULL ) {
printf("\nEnter your name: ");
gets(name);
printf("\nHi %s\n", name);
free(name);
if ( name == NULL ) {
printf("\nGood!");
}
else
printf("\nNOT Good!");
printf("\nHi %s\n", name);
}
return 0;
}
My output:
Code:
Enter your name: c_lady
Hi c_lady
NOT Good!
Hi c_lady
How come after calling the free function I am still able to print the name???
I really don't understand this... isn't this strange?