#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
struct people
{
char name[1024];
int id;
};
void *task (void * arg)
{
printf("task:&arg= %p\n", &arg);
printf("task:&arg= %d\n", *(int*)arg);
}
void *task1 (void * arg)
{
printf("task:&arg= %p\n", &arg);
struct people *p = (struct people *)arg;
printf("name:%s id:%d \n", p->name,p->id);
}
int main(int argc, char const *argv[])
{
pthread_t tid;
int data = 10086;
printf("&data= %p\n", &data);
struct people p;
strcpy(p.name,"A熊");
p.id = 10010;
pthread_create(&tid, NULL, task, &data);
pthread_create(&tid, NULL, task1, &p);
pause();
return 0;
}
执行结果: