That's pretty much it.
The reason for void* is that it allows you to pass a pointer to anything.
You can cast an int to a void* if you want, but the more general approach would be.
Code:
int *threadParams = malloc(sizeof *threadParams);
*threadParams = 42;
_beginthread( silly, 0, threadParams );
...
void silly( void *arg )
{
int *threadParams = arg;
printf( "The silly() function was passed %d\n", *threadParams ) ;
free( threadParams );
}
It's a bit odd for just a single int, but if you had a struct or an array, it would fit very naturally.
Using malloc ensures that you always have a block of memory with a clearly defined scope and owner.
A common mistake is to try this
Code:
void foo ( ) {
int localVar = 42;
_beginthread( silly, 0, &localVar );
}