|
发表于 2004-12-9 22:53:00
|
显示全部楼层
最初由 小锁 发表
- #include<stdio.h>
- #include<malloc.h>
- void foo(int a,char **b)
- {
- (*b) = (char *)malloc(64);
- snprintf((*b),64,"you are %d years old!\n",a);
- }
- int main(void)
- {
- char *f;
- foo(23,&f);
- printf("%s\n",f);
- }
复制代码
没看出什么错误,除了一点不是很好的地方:最后没有free(f),但这在这里不是必须的.
运行起来也出什么错误
看错了,以为这个只是首贴的重新排版 :!! |
|