The information in this article applies to:
SUMMARYIn Microsoft C/C++, expressions involving variables of type "char" are promoted to type "int". MORE INFORMATIONThis is ANSI-specified behavior. Below is Section 3.3.7 from the ANSI specifications, which details the semantics of the shift operator: SemanticsThis means that chars are promoted to integers by default. If you really want a char result, you must cast the final result. The ANSI-specified semantics of all operators specify promotion from char to int, so the size of any char expression will be the sizeof int. This was also the case for Kernighan and Ritchie (K & R) C. The sizes of the int and long expressions stay the same because no promotion takes place. Note that if int is the same size as long rather than short in this implementation, the sizeof both a short expression and a char expression will be 4, as will be the sizeof both an int and a long expression. Sample Code
Additional query words: 8.00 8.00c 9.00
Keywords : kbcode kbCompiler kbVC100 kbVC150 kbVC200 kbVC400 kbVC500 kbVC600 |
Last Reviewed: July 1, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |