even the && operator does not have the law of commutation??
逻辑与运算符竟然没有交换律?
小弟初学VC
while((cipher[i]<'0'||cipher[i]>'9')&&i<cipher.GetLength())
i++;
用这行来跳过字符串cipher中的非数字字符,
谁知程序运行时竟然总是出错(编译通过了),
忽略错误以后运行结果是对的.
我把i<cipher.GetLength()移到前面去变成
while(i<cipher.GetLength()&&(cipher[i]<'0'||cipher[i]>'9'))
i++;
就OK了,
请问大侠们这是怎么回事,
&&运算符有什么特别说道么?
我的函数代码如下,初学者代码
//密文过滤
void CRSA::cipherchange(CString& cipher)
{
int i=0;
CString tempstring="";
while(i<cipher.GetLength())
{
while(i<cipher.GetLength()&&(cipher[i]<'0'||cipher[i]>'9'))
i++;
if(i!=cipher.GetLength())
{
tempstring+=cipher[i];
i++;
}
}
cipher=tempstring;
}