#include <stdio.h>
union bits_32{
unsigned int x;
struct {char b4,b3,b2,b1;} byte;
} ;
int main(int argc, char **argv){
union bits_32 foo;
foo.x=0x100000FA;
printf("%x",foo.byte.b4 & 0xFF);
}
Run Code Online (Sandbox Code Playgroud)
这将输出FA.为什么不输出10因为b4占据了第一个空间?