A team is reviewing a generic container written in ISO C (C11) that passes its elements around as void *. Which of the following statements about void pointers in standard C are true? Select all that apply.
A void * remembers the type of the object it came from, so converting it back to any type is safe.
Adding 1 to a void * advances it by exactly one byte, a behaviour the ISO C standard guarantees.
Converting a double * to void * and back to double * yields a pointer equal to the original.
sizeof(*vp) evaluates to the size of whatever object the void pointer vp currently points to.
struct node *n = malloc(sizeof *n); compiles in C because void * converts implicitly to object pointers.
Unlock full course notes by signing up
Inspecting object bytes through a void pointer
On a little-endian machine where unsigned int is 4 bytes, a program declares unsigned int tag = 0x0A0B0C0D;. A generic dump routine receives the address of tag as a void *vp and converts it with const unsigned char *bytes = vp;. Treat byte 0 as bytes[0], the byte at the lowest address. Give byte 0, byte 1 and byte 3, each as a decimal integer.