I simply want to pass the value of an integer to a thread.
How can I do that?
I tried:
int i;
pthread_t thread_tid[10];
for(i=0;
It better to use of a struct for send more parameters in one :
struct PARAMS
{
int i;
char c[255];
float f;
} params;
pthread_create(&thread_id, NULL, fun, (void*)(¶ms));
then you can cast params to PARAMS* and use of it in pthread routine:
PARAMS *p = static_cast(params);
p->i = 5;
strcpy(p->c, "hello");
p->f = 45.2;