热门

最新

红包

立Flag

投票

同城

我的

发布
2301_80217986
2301_80217986
3 年前
true2301_80217986

求大神

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
《C:动态内存规划》笔试题挑战:题目1:void GetMemory(char *p){ p = (char *)malloc(100);}void Test(void){ char *str = NULL; GetMemory(str); strcpy(str, "hello world"); printf(str);}题目2:char *GetMemory(void){ char p[] = "hello world"; return p;}void Test(void){ char *str = NULL; str = GetMemory(); printf(str);}题目3:void GetMemory(char **p, int num){ *p = (char *)malloc(num);}void Test(void){ char *str = NULL; GetMemory(&str, 100); strcpy(str, "hello"); printf(str);}题目4:void Test(void){ char *str = (char *) malloc(100); strcpy(str, "hello"); free(str); if(str != NULL) { strcpy(str, "world"); printf(str); }}以上四段代码有什么问题,会造成什么后果,欢迎留言~答案即将发布~~
立即登录