How to pass multiple parameters to a thread in C

前端 未结 2 637
一向
一向 2020-12-06 06:21

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

2条回答
  •  一向
    一向 (楼主)
    2020-12-06 06:56

    That's one way. The other usual one is to pass a pointer to a struct. This way you can have different "parameter" types, and the parameters are named rather than indexed which can make the code a bit easier to read/follow sometimes.

提交回复
热议问题