Bit masks let one integer store several yes/no flags.

Flag Masks

flag_masks.c
#include <stdio.h>

int main(void) {
    int flags = ;
    int canRead = (flags & 1) != 0;
    int canWrite = (flags & 2) != 0;
    int canRun = (flags & 4) != 0;

    printf("read=%d write=%d run=%d\n", canRead, canWrite, canRun);
    return 0;
}
#include <stdio.h>

int main(void) {
    int flags = ;
    int canRead = (flags & 1) != 0;
    int canWrite = (flags & 2) != 0;
    int canRun = (flags & 4) != 0;

    printf("read=%d write=%d run=%d\n", canRead, canWrite, canRun);
    return 0;
}
#include <stdio.h>

int main(void) {
    int flags = ;
    int canRead = (flags & 1) != 0;
    int canWrite = (flags & 2) != 0;
    int canRun = (flags & 4) != 0;

    printf("read=%d write=%d run=%d\n", canRead, canWrite, canRun);
    return 0;
}
mask A mask selects one bit position with a value such as `1`, `2`, or `4`.
flag test The `&` operator checks whether a selected bit is present.