Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Created April 27, 2016 05:50
Show Gist options
  • Save shichao-an/f77f1a8a70f34942d3bd480866d73408 to your computer and use it in GitHub Desktop.
Save shichao-an/f77f1a8a70f34942d3bd480866d73408 to your computer and use it in GitHub Desktop.
Bit fields
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
struct
{
bool a: 1;
bool b: 1;
bool c: 1;
} flags = { .b = true };
printf("%s\n", flags.b ? "b.T" : "b.F");
printf("%s\n", flags.c ? "c.T" : "c.F");
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment