#include <iostream.h>void foo();int main()
{
foo();
return 0;
}void foo()
{
int value = 0x5350; // 晕,这块相等是怎么判断的?
if ( value == 'SP' )
{
cout << (char) value << endl;
cout << value << endl; value++;
}
}如程序,怎么判断的?
{
foo();
return 0;
}void foo()
{
int value = 0x5350; // 晕,这块相等是怎么判断的?
if ( value == 'SP' )
{
cout << (char) value << endl;
cout << value << endl; value++;
}
}如程序,怎么判断的?
if ( value == 'SP' )是大字符判断,是可以的。
if ( value == 'SP' )就相当于 if(valu==0x5350)
Character constants are specified as one or more characters enclosed in single quotation s. For example:char ch = 'x'; // Specify normal character constant.
int mbch = 'ab'; // Specify system-dependent
// multicharacter constant.
wchar_t wcch = L'ab'; // Specify wide-character constant.
Note that mbch is of type int. If it were declared as type char
摘自:ms-help://MS.VSCC/MS.MSDNVS.2052/vclang/html/_pluslang_c.2b2b_.character_constants.htm
编译器理解为:
int value=0x5350;
如果是 int value='SPSP';
则理解为 int value=0x53505350;
最多4个字符,因为size(int)=4;