C question

Subscribe to C question 3 posts, 1 voice

 
Avatar Kyle 6 posts

Is it possible to allocate storage smaller than 1 byte?

In many C programs, there is something or the sort:

[code] typedef char bool; [/code]

And then ‘bool’ is used to declare integers used as yes/no values.

However, it still uses more storage than it needs, since chars are 1 byte, thus bools are too. But bools should theoretically need only 1 bit to function.

Is this the best we can do?

 
Avatar Kyle 6 posts

Is there a code flag? Clearly my guess of “[code] and [/code]” was incorrect.

Sorry guys I’m new to this forum.

 
Avatar Kyle 6 posts

And I know how bit-vectors are used to get around this. But I was just wondering if there was a way to grab exactly 1 bit.