void *get_memory1(int size) //可以申请成功
{
char *p=(char *)malloc(size);
if(p ==NULL){
printf("malloc fail\n");
return;
}
return p;
}
void get_memory2(char *p , int size) //不能申请成功
{
p=(char *)malloc(size);
}
void get_memory3(char **p, int size) //可以申请成功
{
char *ptr = *p;
ptr = (char *)malloc(size);
}
void main()
{
char *p;
p=get_memory2(100);
get_memory3(&p, 100);
get_memory2(p, 100);
}