#include <stdio.h>
#include <stdlib.h>
char *namefunct(void);
int main(int argc, char *argv[])
{
printf("Hello, %s!!!\n", namefunct()); //namefunct is not returning tmp_name
}
char *namefunct(void)
{
char *name = malloc(sizeof(char) * 10);
scanf("%s", name);
char *tmp_name = name;
free(name);
return tmp_name;
}
OUTPUT: ferf Hello, !!! //namefunct is not returning tmp_name How can i free the memory which is allocated in the namefunct()?