Multiple arguments to function called by pthread_create()? Multiple arguments to function called by pthread_create()? c c

Multiple arguments to function called by pthread_create()?


Because you say

struct arg_struct *args = (struct arg_struct *)args;

instead of

struct arg_struct *args = arguments;


use

struct arg_struct *args = (struct arg_struct *)arguments;

in place of

struct arg_struct *args = (struct arg_struct *)args;


main() has it's own thread and stack variables. either allocate memory for 'args' in the heap or make it global:

struct arg_struct {    int arg1;    int arg2;}args;//declares args as global out of main()

Then of course change the references from args->arg1 to args.arg1 etc..