I find that there is no native bool
type. People either use int
or char
- though it seem that int
might be more frequently used than char
? Is this true?
My first impulse was to use char
as it is a smaller data type, but there something I've missed? Is int
better for boolean values, and if so - why?
There is a
_Bool
in C99, and abool
if you includestdbool.h
.If you don't have it (a decently modern compiler), use
int
, it's usually the fastest type. The memory savings of usingchar
are likely negligible.