Casting a byte array to a struct pointer depends on endiannes or memory alignment?
- by Petruza
Suppose this code:
unsigned char list[3] = { 1, 2, 3 };
struct _struct{
unsigned char a;
unsigned char b;
unsigned char c;
} *s;
s = ( _struct * ) list;
Can I assume that always s->a == 1, s->b == 2, s->c == 3 ?
Or it will depend on the system's endianness or memory alignment?