I have following code from an object-oriented programming C book:
{
struct Set { int count; };
struct Set * set = malloc(sizeof(struct Set));
void * p = set;
const size_t size = * (const size_t *) p;
}
I cant understand how and why last line works. size_t size
is dereferenced value of pointer of type size_t
. pointer of type type_t is cast from void* p
.
What is happening when I cast void*
to type_t*
, I could not find any information in the book or online tutorials. Can someone explain it to me or refer me to a good tutorial?