How to pass more than one value as an argument to a thread in C?

前端 未结 3 2008
梦如初夏
梦如初夏 2021-01-21 13:10

In C, how can i pass more than one argument to a thread?

Normally, I do it in a way like,

 pthread_create(&th,NULL,dosomething,(void*)connfd);


void         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 13:17

    Pack the several values inside a struct on the heap (so malloc it and fill it before), then call pthread_create with a pointer to that struct.

提交回复
热议问题