void GetMemory(char **p, int num){ if(NULL == p && num <= 0)//1 return; *p = (char*)malloc(num); return; } void main(void){ char *str = NULL; GetMemory(&str, 80); //2 if(NULL != str){ strcpy(&str, "hello"); //3 printf(str); } return true; //4 }
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题