|
|
|
|
|
by peterfirefly
1148 days ago
|
|
sizeof() returns the number of "units" that something -- an expression or a type -- takes up. What do you think those units are? They are literally defined as "characters". sizeof(char) is always 1. Your confusion (besides the pointer thing) is that 'x' is a funny way to write an int, not a char. |
|
Yes, this might be it. So the way to get a `char` value that contains "c" is to use type coercion and write it as `(char) 'c'`. This changes the representation in memory so that it now takes up only one byte rather than four, right?