sizeof(char) and sizeof(bool) are both equal to 1 (in my compiler/system/whatever, I've heard that it's not always the same value), a bool can only store true or false while a char can take more values and can act as multiple bool variables using bitwise operators (8 bits, each bit can be used as 1 bool for a total of 8 bools)
So is there any advantage on using bool instead of char?
So aside from readability is there anything else? I've read somewhere that int gets processed faster than short or byte even if takes more memory. Is there any difference in terms of speed between char and bool?
bool
can only storetrue
orfalse
. – juanchopanzasizeof(bool)
isn't necessarily1
, implementation may choose a bigger size. – Yu Haobool
you would ask why there is nobool
and onlychar
. – Maroun