Answer the question
In order to leave comments, you need to log in
How many bits does the CHAR_BIT macro have?
In many sources it is written that the CHAR_BIT macro has one eight-bit byte. In the example below, this is not entirely true, rather not true at all.
#include <stdio.h>
#include <limits.h>
int main(void){
char size = CHAR_BIT * sizeof(char);
printf("%lu\n", sizeof(char));
printf("%lu\n", sizeof(CHAR_BIT));
printf("%u\n", size);
return 0;
}
byte 1
4
8
Answer the question
In order to leave comments, you need to log in
CHAR_BIT - macro, the number of bits in a char. The standard is at least 8 (but it may well be more).
sizeof(char)
= 1 by definition (sizeof measures everything in chars)
sizeof(CHAR_BIT)
- given that CHAR_BIT is defined something like #define CHAR_BIT 8
, here you calculatesizeof(int)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question