绝版面试题

时间:2015-05-02 18:35:31
【文件属性】:

文件名称:绝版面试题

文件大小:539KB

文件格式:DOC

更新时间:2015-05-02 18:35:31

c++

153、 回答下面的问题 (1).Void GetMemory(char **p, int num){ *p = (char *)malloc(num);//一级指针的值被修改 } void Test(void){ char *str = NULL; GetMemory(&str;, 100);//传递的是一级指针的地址 strcpy(str, "hello"); printf(str); } 请问运行Test 函数会有什么样的结果? 答:输出“hello” (2).void Test(void){ char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NULL){ strcpy(str, “world”); printf(str);} }


网友评论