下面的示例编译通过,但输出结果相当奇怪:
输出是:
有人能解释一下为什么吗?
如果有关系的话,我正在使用g++ 4.3.0。
#include <iostream>
#include <cstring>
struct A
{
int a;
char b;
bool c;
};
int main()
{
A v;
std::memset( &v, 0xff, sizeof(v) );
std::cout << std::boolalpha << ( true == v.c ) << std::endl;
std::cout << std::boolalpha << ( false == v.c ) << std::endl;
}
输出是:
true
true
有人能解释一下为什么吗?
如果有关系的话,我正在使用g++ 4.3.0。