Home > Mobile >  Wondering why the size of my char is 4 bits?
Wondering why the size of my char is 4 bits?

Time:08-04

I am wondering why the size of my char is 4 bit? Shouldn't it be 8 bits by todays standards?

#include <stdio.h>
#include <limits.h>

int main(){
printf("%zu\n", sizeof(CHAR_BIT));
return 0;
}

I am using a 2015 built Laptop i guess with a x64 processor.

Program Output:

4

CodePudding user response:

CHAR_BIT is something like

#define CHAR_BIT 8

As such, you are printing the size of an int, which is 4 bytes for you.

I think you wanted

printf( "%d\n", CHAR_BIT );
  • Related