Understanding sizeof(char) in 32 bit C compilers

Viewed 24822

(sizeof) char always returns 1 in 32 bit GCC compiler.

But since the basic block size in 32 bit compiler is 4, How does char occupy a single byte when the basic size is 4 bytes???

Considering the following :

struct st 
{
int a;
char c;
};

sizeof(st) returns as 8 as agreed with the default block size of 4 bytes (since 2 blocks are allotted)

I can never understand why sizeof(char) returns as 1 when it is allotted a block of size 4.

Can someone pls explain this???

I would be very thankful for any replies explaining it!!!

EDIT : The typo of 'bits' has been changed to 'bytes'. I ask Sorry to the person who made the first edit. I rollbacked the EDIT since I did not notice the change U made. Thanks to all those who made it a point that It must be changed especially @Mike Burton for downvoting the question and to @jalf who seemed to jump to conclusions over my understanding of concepts!!

8 Answers
Related