15,440
社区成员
发帖
与我相关
我的任务
分享
void GetMemory(char **p)//改了
{
*p= (char *)malloc(100);//改了
}
void Test(void)
{
char
*str = NULL;
GetMemory(&str); //改了
strcpy(str, "hello world");
printf(str);
}
void GetMemory(char *p) //(2) p->NULL, p和str值相同
{
p= (char *)malloc(100); //(3)p指向新空间了,str未变
}
char *str = NULL; //(1) str->NULL
GetMemory(str);
//(4) str没有变,还是NULL