I encountered a problem.I try to change the pointer,but pointer does not change. Here is my code:
void TestPoint(char* point)
{
point=new char[10];
}
int ma
That's because function TestPoint receives a copy of the test variable, modifies it (assigning pointer to allocated memory) and then discards. If you imagine replacing char* with, for instance, int, things may get clearer.
The very minimal change you can do is rewrite TestPoint signature in the following way
void TestPoint(char*& point)
thus passing test variable via reference. These online lessons may be of help. Chapters 7.2 - 7.4 are about passing arguments to function.