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,...)
            Asked
            
        
        
            Active
            
        
            Viewed 148 times
        
    0
            
            
         
    
    
        Shubhanshu
        
- 73
- 5
1 Answers
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
- 
                    Pretty much clear Sir. Thank you @timrau – Shubhanshu Jan 29 '15 at 05:30