Okay, here's an example of what you want to do:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
struct test {
char str[32];
int x;
};
void *tfunc() {
struct test *eg = malloc(sizeof(struct test));
strcpy(eg->str,"hello world");
eg->x = 666;
pthread_exit(eg);
}
int main (void) {
pthread_t id;
struct test *resp;
pthread_create(&id,NULL,tfunc,NULL);
pthread_join(id,(void**)&resp);
printf("%s %d\n",resp->str,resp->x);
free(resp);
return 0;
}
Take a close look at the pointer to a pointer used in the red line, and how the struct returned must be malloc'd global memory in tfunc().