it simply doesn't change when the function exits as though it's passing it by value or something, even though it gives the pointer address. |
You need to think clearly about what it is you're trying to pass by reference, and what you're changing the value of. By passing in a
string *
as the argument, you're effectively passing the
string itself by reference. But you are passing the
pointer to the string by value.
In your function, the thing you are trying to change is not the value of the string, but the value of the
pointer to the string. That's the thing you're passing by value, so the change in that pointer won't be reflected in the calling code.
Remember, a pointer is just a variable like any other. It has a value, which can be changed. It's just that that value is a memory address.
All of kbw's solutions will work.