If I have a function return a pointer to a string, something like below (maybe different sytnax), is that string freed from memory at the end of the calling function foo?
void foo(){
char *string = function();
// Is string freed at the end of this function?
}
char *function(){
return "string";
}
I'm asking this because I understand that if I were to malloc() the memory, it would not be freed at the end of foo (unless I go and free it myself).