This is one of the very popular interview questions, so take a good look at it!.
int myvar = 100;
ptr = &myvar;
//Use pointer myptr.
Do you think this works? It does not!.
Arguments in C are passed by value. The called function changed the passed copy of the pointer, and not the actual pointer.
There are two ways around this problem
Pass in the address of the pointer to the function (the function needs to accept a pointer-to-a-pointer).
return_string(/* Pass the address of the pointer */&string);
boolean return_string(char **mode_string /*Pointer to a pointer! */)
*string = (char *) malloc(100 * sizeof(char)); // Allocate memory to the pointer passed, not its copy.
DISCARD strcpy((char *)*string, (char *)?Something?);
Make the function return the pointer.
char *temp = "string";