size - In C, why is sizeof(char) 1, when 'a' is an int? -


i tried

printf("%d, %d\n", sizeof(char), sizeof('a'));

and got 1, 4 output. if size of character one, why 'c' give me 4? guess it's because it's integer. when char ch = 'c'; there implicit conversion happening, under hood, 4 byte value 1 byte value when it's assigned char variable?

in c 'a' integer constant (!?!), 4 correct architecture. implicitly converted char assignment. sizeof(char) 1 definition. standard doesn't units 1 is, bytes.


Comments