Charles Krug said:
The OP wanted bits per byte. C defines (freely speaking) char to be
"one byte" (IANALL).
So CHAR_BIT is the number of bits in a byte.
Yes, CHAR_BIT is by definition the number of bits in a byte, which is
exactly what the OP was asking about. The thread wandered into a
discussion of how to compute CHAR_BIT without actually using the
CHAR_BIT macro. There are several ways to do this, none of them
useful if CHAR_BIT is available, but it's an interesting exercise.
(It could also be useful in the unlikely event that CHAR_BIT is
defined incorrectly; this could possibly happen if the compiler and
<limits.h> are out of sync.)