我写了这个程序:
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
struct A {
bool a;
bool b;
bool c;
bool d;
};
struct B {
int a;
};
int main() {
struct A* pa = malloc( sizeof(struct A) );
struct B* pb = (struct B*) pa;
pa->a = 0;
pa->b = 1;
pa->c = 0;
pa->d = 0;
printf("value of pint is %i\n", pb->a);
return 0;
}
我希望它打印 2 (0010),但输出是 256。任何一个云帮助说明这段代码有什么问题?