|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
The sizeof operator #include "Stdio.h>;
Void main ()
{
Char ch= 'one';
Printf ( "%d\n", sizeof (ch));
Printf ( "%d\n", sizeof ( 'one'));
}
K&R described in the book : In the formula, each CHAR were converted to INT. So why is the result of one and four VC? I understand this is wrong then? |
The sizeof operator Char in the different systems which are not necessarily the same space occupied by the bar. |
The sizeof operator Ch is a character variable, sizeof (ch) = sizeof (char) is one.
ANSI requirements intger character constant with type int, so sizeof ( 'l') value sizeof (int) of the same value, in your platform, the value of 4.
Wchar_t c is the type of different size and char. |
The sizeof operator Add that in C + +, sizeof ( 'c') value is 1, not C + + int parameters of the characters expansion. |
| |