Bool array vs bit array in C

I need to implement an efficient bitmap in C. From what I saw, C does not support this, so you can use an array of integers (on one site I was looking at), and then use the transition to access individual bits. Would it be simple to declare the bool array the same, or is it less memory efficient?

+5
source share
1 answer

Yes, a simple _Bool array requires more memory than an array of integers in combination with some bit offset. The _Bool array stores one bit of data in sizeof(_Bool) space (usually one byte). An integer array can store many more bits per byte (minimum 8).

+3
source

Source: https://habr.com/ru/post/1207075/


All Articles