33,311
社区成员
发帖
与我相关
我的任务
分享
char * getmemory(void)
{
char *p=(char *)malloc(100);
strcpy(p,"hello,world");
return p;
}
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
void getmemory(char **p)
{
*p=(char *) malloc(100);
strcpy(*p,"hello world");
}
int main( )
{
char *str=NULL;
getmemory(&str);
printf("%s\n",str);
free(str);
return 0;
}