关于指针的问题?
程序1:
void GetMemory1(char *p, int num)
{
p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(str, 100);
strcpy(str, "hello");
printf(str);
}
程序2:
void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}
这二段程序有什么区别啊,我怎么感觉是一样的啊?