Let's dissect this.
In all cases, sizeof(char) == 1
, and the list
array will have its three members at memory locations list
, list + 1
, and list + 2
.
The situation with the struct
is not quite as clear. The Standard guarantees that the members will be allocated in increasing memory locations, but not that they will be contiguous. The compiler is free to introduce padding between members, and padding at the end.
Therefore, s->a == 1
will always be true. If the implementation puts the unsigned char
s in the struct
adjacent (and most will), then the other equalities will necessarily be true.
By the way, calling a struct
_struct
may cause problems. A name beginning with an underscore in the global namespace is reserved for the implementation.