I am in need of implementing an efficient bit array in C. From what I have seen C does not support this so you can use an array of integers (according to one site I looked at) and then use a shift to access individual bits. Would simply declaring a bool array be the same thing or is this less memory efficient?
Yes, a simple _Bool
array require more storage than an array of integers combined with some bit-shifting. The _Bool
array stores one bit of data in a sizeof(_Bool)
space (normally a single byte). The integer array can store many more bits per byte (minimum 8).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With