我能够打印出int的地址和值,但不能打印出union的字符.为什么会这样
#include <iostream>
using namespace std;
union Endian
{
int i;
char c[sizeof(int)];
int j;
};
int main(int argc, char *argv[]) {
Endian e;
e.i = 20;
cout << &e.j;
cout << &e.i;
cout << &e.c[0]; //Why can't I print this address
cout << e.c[1]; // Why can't I print this value
}
Run Code Online (Sandbox Code Playgroud)
O/P:0x7fff5451ab68 0x7fff5451ab68
c++ ×1