sizeof 问题
sizeof( 'N ')
sizeof( 'NULL ')
sizeof( '\n ')
为什么返回值都是4呢?
[解决办法]
K & R说:
A character constant is a sequence of one or more characters enclosed in single quotes as in 'x '. The value of a character constant with only one character is the numeric value of the character in the machine 's character set at execution time. The value of a multi-character constant is implementation-defined.
注意两点:
1、在C语言中(C++是不同的),字符常量(character constant)是字符的机器表示的数值,也就是说,是一个整数(int型),所以sizeof的结果是整数的大小。
2、一个字符常量的引号内有多个字符,结果是“implementation-defined”(由实现定义的)。