Bit flags
Keep many on/off settings in one unsigned int: set, clear, toggle and test flags, read file permissions, and avoid the & and == precedence trap.
- The skill
- Store many on/off settings in one number and set, clear, toggle and test them safely.
- You make
- Status effects for a game character, file permissions as text and a controller that spots new button presses.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 35 Shifts and masks. Free to try: C Foundations and the playground.
Passed
You can now
Step 1 of 8
exercise_1.c
You've reached the good stuff.
4 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
C, 32-bit: int and pointers are 4 bytes