0

I have a task in which i have to pass more than one parameter to the thread calling function in C. to be clear pthread_create(&threadName, NULL, search_thread, parameter1) is my thread creation, in which i want to pass more parameter for search_thread function. Is it possible? basically i want pthread_create(&threadName, NULL, search_thread, parameter1, parameter2,...)

Shubhanshu
  • 73
  • 5

1 Answers1

7

The last parameter of pthread_create() is void*. You could always define a structure to encapsulate the multiple parameters, cast its address into void*, and cast it back inside search_thread().

timrau
  • 22,578
  • 4
  • 51
  • 64