C++ Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void GetMemory( char **pp )
{
*pp = (char *) malloc( 100 );
}
int main(int argc, const char *argv[])
{
char *p = NULL;//new char;
GetMemory(&p);
strcpy( p, "hello world" );
printf("%s\n",p);
}
内存分析图: