'How do I pass a struct as an argument in pthread in c?
How do I pass a struct as an argument in pthread in c:
void * aFunction (aStruct1 *theStruct1, aStruct2 *theStruct2, aStruct3 *theStruct3){
printf("%s", theStruct1->text);
}
pthread_t thread[2];
pthread_create(&thread[0], NULL, aFunction, "how do i pass all the struct argument here (theStruct1, theStruct2 , theStruct3)");
pthread_create(&thread[1], NULL, aFunction, "how do i pass all the struct argument here (theStruct1, theStruct2 , theStruct3)");
pthread_join(thread[1],NULL);
pthread_join(thread[2],NULL);
I have tried calling it as so with no result:
void * aFunction (aStruct1 *theStruct1, aStruct2 *theStruct2, aStruct3 *theStruct3){
printf("%s", theStruct1->text);
}
pthread_t thread[2];
pthread_create(&thread[0], NULL, aFunction(theStruct1, theStruct2 , theStruct3), NULL);
pthread_create(&thread[1], NULL, aFunction(theStruct1, theStruct2 , theStruct3), NULL);
pthread_join(thread[1],NULL);
pthread_join(thread[2],NULL);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
