跳过导航.
主页

请大家看看北京德信德这个考题????

北京

编译和链接都没问题,运行时候出错!!!!!!!!
#include
#include
#include
void get(char*);
main()
{ char *s=NULL;
get(s);
strcpy(s,"hello world");
printf(s);
return 0;
}
void get(char *p)
{ p=(char*)malloc( 100);
}



评论查看选项

选择您喜欢的显示评论的模式,并点击"保存设置"来激活您所做的改变。

void get(char **p)
{ *p = (char*)malloc( 100);
}
-------------------------------
get(&s);

在main()中还要free.

void get(char*&);
main()
{ char *s=NULL;
get(s);
strcpy(s,"hello world");
printf(s);
return 0;
}
void get(char*& p)
{ p=(char*)malloc( 100);
}