CC++及数据结构笔试题集锦.docVIP

  • 7
  • 0
  • 约1.21万字
  • 约 16页
  • 2019-05-31 发布于浙江
  • 举报
二:改错题,只能在原来的基础上增加代码,不能删除代码 #include #include void foo(int age,char *b) { b = (char *)malloc(64); sprintf(b,Your Age is %d,age); } int main() { char *f; foo(23,f); printf(%s\n,f); } 答案 版本1 #include #include void foo(int age,char **b) { *b = (char *)malloc(64); sprintf(*b,Your Age is %d,age); } int main() { char **f; foo(23,f); printf(%s\n,**f); return 0; } 版本2 #include #include void foo(int age,char *b) { b = (char *)malloc(64); sprintf(b,Your Age is %d,age); } int main() { char *f; foo(23,f); printf(%s\n,f); free(f);//不要忘了free; } 三:有程序片断如下 int mai

文档评论(0)

1亿VIP精品文档

相关文档