The method I posted is from C language, while thekashap's method is c++. One is not safer than the other. Which method you choose would be a personal preference but in a c++ program you should probably use the c++ method for consistancy.
As a rule of thumb, if you need to modify a variable in another function, you need to pass an address of it to the called function.
In this case you wanted to modify the char pointer and hence need to pass the pointer to the char pointer i.e. the address of the char pointer. References in C++ are just glorified pointers which act as the syntactic sugar.