If q
is a pointer to any object type, then casting it to a character type provides a means to access the bytes of the representation of the pointed-to object, if any. However, if q
is a pointer to a structure type then the code you present does not access the members per se. Although the representation of an instance of the structure type comprises representations of all the structure members, (char*) q + 1
is not selecting a member, but rather a byte (in the form of a pointer to that byte) -- the one at offset 1 from the beginning of the structure. That byte could be part of the first member (which starts at offset 0), part of the second member, or not part of any member.
Given (char*) q + 1
being a pointer to the byte at offset 1 from the start of object *q
, and *q
being at least two bytes in size, the expression *( (char*) q + 1)
evaluates to the value of that byte. It is equivalent to ((char *)q)[1]
.