私はこのプログラムを書きました:
#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 です。