Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Wondering why the size of my char is 4 bits?

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

4

>Solution :

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 );
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading