warning: function returns address of local variable [-Wreturn-local-addr]

C
// Use memory allocation!!

char *str_to_ret = malloc (sizeof (char) * required_size);
Source

Also in C: