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.
How can I use a bit to store a boolean value in C?
Moderator: Board moderators
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.
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.
My signature:
- Please make discussion about the algorithm BRFORE posting source code.
We can learn much more in discussion than reading source code. - I HATE testing account.
- Don't send me source code for debug.
Boolean in C
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.

[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.

