In my project we have a piece of code like this:
// raw data consists of 4 ints
unsigned char data[16];
int i1, i2, i3, i4;
i1 = *((int*)data);
i2 = *((int*
You may want to show him how things can differ depending on the compiler version:
Apart from alignment there is a second problem: the standard allows you to cast an int*
to char*
but not the other way around (unless the char*
was originally casted from an int*
). See this post for more details.