#include <iostream>
using namespace std;
void GetMem(char** p, int n)
{
*p = (char*)malloc(sizeof(char)*n);
};
void main()
{
char c[] = "a";
char* ptr = c;//NULL;
GetMem(&ptr, 100);
strcpy(ptr,"hello!");
cout << ptr << endl;
cout << *ptr << endl;
cout << &ptr << endl;
}
see the procedure:
1.
2.
3.
4.
5.