Created
September 30, 2012 15:10
-
-
Save iamben/3807074 to your computer and use it in GitHub Desktop.
mem padding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
union data { | |
struct gg_t { | |
char a; | |
char b; | |
int c; | |
} gg; | |
struct yy_t { | |
char a; | |
int b; | |
char c; | |
} yy; | |
}; | |
int main(int argc, const char *argv[]) | |
{ | |
data aaa; | |
aaa.yy.a = 'c'; | |
aaa.yy.b = 'c'; | |
aaa.yy.c = 'c'; | |
std::cout << "sizeof data: " << sizeof(data) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment