Skip to content

Instantly share code, notes, and snippets.

@khajavi
Last active December 17, 2015 19:39
Show Gist options
  • Save khajavi/5662424 to your computer and use it in GitHub Desktop.
Save khajavi/5662424 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
struct A {
bool a:1;
bool b:1;
bool c:1;
bool d:1;
};
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 = 1;
pa->d = 0;
printf("value of pb->a is %i\n", pb->a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment