I am currently working my way through threads in C, and I am currently stuck on using my one parameter (an array to be sorted) on thread creation as the array to work with. For an example:
void* sort(void* param)
How do I grab param so that it can be used as an int array local variable?
Also to return the sorted array would I just do return array on the last line,
and do something like int sorted_array[] = pthread_create(&tid, &attr, sort, &un_sorted_array) to capture it?
I'm new to C to any help would be appreciated? Using void pointer to an array The solution here still gave me an invalid initalizer error.
void* merge(void* arg) {int *arg_ptr[] = (int*) arg; int arr[] = *arg_ptr;}gives me an invaild initializer errorvoid* merge(void* arg) { int *arg_ptr = (int*) arg; }. To get the result you need to callpthread_join.