摘要: 摘自: http://blogread.cn/it/article/1266?f=savoid 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”);将使程序崩溃。子函数开辟空间p,用于... 阅读全文
posted @ 2013-05-21 17:00 谭小羽 阅读(999) 评论(0) 推荐(0) 编辑