October 2018
Beginner
794 pages
19h 23m
English
The preceding heading gives it away: we pass a data structure. But how, exactly? Allocate memory to a pointer to the data structure, initialize it, and pass the pointer typecast as void *. (In fact, this is a very common approach that C programmers use.) In the thread routine, as usual, typecast and use it.
To bring clarity, we will try this out ( ch14/param_passing/struct_as_param.c):
/* Our data structure that we intend to pass as a parameter to the threads. ...
Read now
Unlock full access