请大家看看北京德信德这个考题????
由 dongfangshuo 于 周四, 2005-11-03 16:38 提交。
北京
编译和链接都没问题,运行时候出错!!!!!!!!
#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);
}