I am trying to pass two parameters to a thread in C. I have created an array (of size 2) and am trying to pass that array into the thread. Is this the right approach of pass
Since you pass in a void pointer, it can point to anything, including a structure, as per the following example:
typedef struct s_xyzzy {
int num;
char name[20];
float secret;
} xyzzy;
xyzzy plugh;
plugh.num = 42;
strcpy (plugh.name, "paxdiablo");
plugh.secret = 3.141592653589;
status = pthread_create (&server_thread, NULL, disk_access, &plugh);
// pthread_join down here somewhere to ensure plugh
// stay in scope while server_thread is using it.