This all boils down to pass-by-value vs. pass-by-reference.
The pointer isn't set in the main() because the pointer was passed to the function that allocates memory using pass-by-reference. This means that it wasn't the actual pointer from the main that was assigned the allocated memory, it was a copy. Once the memory allocation function set_mem() completes the address of the returned memory is lost.