Page 1 of 1
How can I use a bit to store a boolean value in C?
Posted: Thu Jan 02, 2003 11:42 am
by yatsen
I usually use data type int or char to store a boolean value(0,1).
But sometimes the table is so big.
So if I can use a bit to store a boolean value, it will reduce the memory used.
Please help me, thanks.
Posted: Sat Jan 04, 2003 6:21 pm
by ..
I think this problem should be discussed in "Help on languages" part.........
I use C to write program. When I need to use bit to store boolean, I will use the bit-wise operators ( ^, |, &, <<, >>). Using these operators can let you control the value of a bit in a int or char.
Boolean in C
Posted: Thu Jan 16, 2003 7:07 am
by 27584NX
To store boolean values, I use the
[c]_Bool myBooleanVar ;[/c]
The values accepted are 0 or 1. (I think true are false will generate errors)
But this _Bool is not accepted by the GCC compiler (which is the one I think the judge uses), but runs ok on LCCwin32.
Hope I helped you.

Posted: Sat Feb 22, 2003 7:39 pm
by imranul
why not use Bit-Field?