|
|
发表于 2006-5-8 10:48:15
|
显示全部楼层
$ gcc -o test test.c
test.c: In function `main':
test.c:15: warning: passing arg 1 of `foo' from incompatible pointer type
$ ./test
test
xQ=
- #include <stdlib.h>
- #include <string.h>
- void foo(char *buf, int len)
- {
- buf = (char *)malloc(2000);
- strcpy(buf, "hello");
- }
- int main()
- {
- char buf[1000];
- strcpy(buf, "test");
- printf("%s\n", buf);
- foo(buf, 1000);
- printf("%s\n", buf);
- return 0;
- }
复制代码
$ gcc -o test test.c
$ ./test
test
test |
|