finally get it
Code:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct
{char*name;
int age;
int arr[10];
}person;
void*fun(void *arg);
int main()
{
person x;
x.name="frommain";
x.age=100;
int i;
pthread_t thrd;
void *exit;
pthread_create(&thrd,NULL,fun,&x);
pthread_join(thrd,&exit);
printf("-------------- in main\n");
person *result=(person*)exit;
printf("name is %s\n",result->name);
printf("age is %d\n",result->age);
for(i=0;i<10;i++)
{printf("a[%d] is %d\n",i,result->arr[i]);}
free(exit);
return 0;
}
void*fun (void*arg)
{int i;
person *ax=(person*)arg;
printf("name is %s\n",ax->name);
printf("age is %d\n",ax->age);
person *ptr =(person*)malloc(sizeof(person));
ptr->name="alipapa";
ptr->age=10;
for(i=0;i<10;i++)
{ptr->arr[i]=i;}
//printf("name is %s\n",ptr->name);
//printf("age is %d\n",ptr->age);
return ptr;
}