Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // thread_function.c
- // gcc -o thread_function thread_function.c
- #include <stdio.h>
- #include <pthread.h>
- #include <stdlib.h>
- void* thread_function(void) {
- char *a = malloc(10);
- strcpy(a,"<Hello World>");
- pthread_exit((void*)a);
- }
- int main() {
- pthread_t thread_id;
- char *b;
- pthread_create (&thread_id, NULL,&thread_function, NULL);
- // Here we are reciving one pointer value. Thus, we need double pointer:
- pthread_join(thread_id,(void**)&b);
- printf("b is %s\n",b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement