r/C_Programming • u/Yha_Boiii • Jul 07 '26
If statement checking a bool array?
Hi,
I need a custom sized bit vector so uint8_t won't suffice so the idea was to just initiate a bool array with size so then say i want to compare it. Ex**. the bool array is 6 bits and tried with `if (bool_var = 011001) { // do something}`, i suspect it comes just compares to an int given it compiles and wont run. Any idea on how to make it work?**
0
Upvotes
View all comments
Show parent comment
3
u/F1nnyF6 Jul 08 '26
The 0b* syntax is just a way to express a number in binary, in the same way 0x* is a way to represent it in hex. It is just syntax sugar over a number that the compiler will treat exactly the same.
As far as the compiler is concerned, 0b11111111 = 0xFF = 255. They are exactly equivalent