void getMemory(char *p) { p=(char *)malloc(100); } char * getMemory(char *p) { char ch[]="hello world"; return ch; } char * getMemory(char **p) { *p=(char*)malloc(100); return *p; } int main() { char *str=NULL; // getMemory(str); getMemory(&str); if(str!=NULL) cout<<"get Memory success"<<endl; }
时间: 2024-11-05 21:52:55