1
0

21-bit-field.c 346 B

1234567891011121314151617181920
  1. #include <stdio.h>
  2. struct Flags {
  3. unsigned int isRed : 1;
  4. unsigned int isGreen : 1;
  5. unsigned int isBlue : 1;
  6. };
  7. int main() {
  8. struct Flags f;
  9. f.isRed = 1;
  10. f.isGreen = 0;
  11. f.isBlue = 1;
  12. printf("Red: %u\n", f.isRed);
  13. printf("Green: %u\n", f.isGreen);
  14. printf("Blue: %u\n", f.isBlue);
  15. return 0;
  16. }