int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
I am trying to pass in an argument as a pointer through pthread_create.
typedef struct {
int input;
int threadNum;
} ARGS;
ARGS argument16[16];
for (x = 0; x < 16; x++) {
printf("pthread16_created: %d\n", x);
argument16[x].threadNum = 16;
argument16[x].input = x % 4;
pthread_create(&(threads16[x]), NULL, funct, argument16[x]);
}
This is giving me error: incompatible type for argument 4 of ‘pthread_create’
How do I pass in a ARG type pointer in a array of ARGS? I can't seem to figure it out. I know arrays are already a pointer, but not sure how to pointer to a certain element in the array. Thank you
&argument16[x]In other words, you want to pass the address of the element, not the element itself.