You need to use double pointer there so that foo() can allocate memory for the pointer in main(). You can do the same with as many other pointers as you like, it is not limited to just one pointer. This solves the problem is returning more than one string at the same time.
void foo( char ** ptr)
{
*ptr = malloc(255); // allocate some memory
strcpy( *ptr, "Hello World");
.
}
'
int main()
{
char *ptr = 0;
foo( &ptr ); // <<< pointer to a pointer
<snipped>
}