|

楼主 |
发表于 2007-6-28 18:11:18
|
显示全部楼层
- #include <stdio.h>
- #include <pthread.h>
- #include <string.h>
- int a = 1;
- void *
- print(char *s, int i)
- {
- printf("print(): s = %s\ni = %d\n", s, i);
- }
- int main()
- {
- int err;
- pthread_t tid1, tid2;
- struct st
- {
- char s[20];
- int i;
- };
- struct st aa;
- strcpy(aa.s, "lixiaoya");
- aa.i = 5;
- err = pthread_create(&tid1, NULL, print, &aa);
- if(err != 0)
- {
- printf("print() error\n");
- return;
- }
- return 0;
- }
复制代码
test@szxdb:~/lxy/unix> gcc asd.c -lpthread
asd.c: In function `main':
asd.c:25: warning: passing arg 3 of `pthread_create' from incompatible pointer type
test@szxdb:~/lxy/unix> ./a.out
print(): s = lixiaoya
i = 1083538564
i为什么不是5呢? |
|