If I create a void pointer, and malloc a section of memory to that void pointer, how can I print out the individual bits that I just allocated?
For example:
The malloc allocates bytes.
for (i = 0; i < 24; ++i) printf("%02xh ", p[i]);
would print the 24 bytes. But if cast to an int, you'll need to adjust the loop:
for (i = 0; i < 24; i += sizeof(int)) printf("%xh", *(int *)&p[i]);
But then, if you know you want an int, why not just declare it as an int?