摘要:
C++内存问题(很多公司面试的题目,值得一看,看懂了别忘了告诉我)void GetMemory(char *p){p=(char*)malloc(100);}void Test(void){char *str = NULL;GetMemory(str);strcpy(str,"helloworld");printf(str);}请问运行Test函数会有什么样的结果?答:程序崩溃。因为GetMemory并不能传递动态内存,Test函数中的str一直都是NULL。strcpy(str,"helloworld");将使程序崩溃。char *GetMemory( 阅读全文
posted @ 2010-03-19 19:09 xublogs 阅读(353) 评论(0) 推荐(0)
浙公网安备 33010602011771号