int num = *(int *)number; What does this do?
The (int *) part casts the variable number to a pointer to an int, then the * in front dereferences it to an int.
The function takes a void*
, but somehow it knows (perhaps it's required in some documentation somewhere) that the pointer it's given actually points to an int
.
So, (int*)number
is "the original pointer, converted to an int*
so that I can read an int
from it", and *(int*)number
is the int value that it points to.