Java的ClassLoader机制

C语言的逻辑运算符探究

tcsong posted @ Mon, 24 Aug 2009 12:25:11 -1100 in Programming Language with tags c operator logic , 1127 readers

测试程序  

 

int methodA(){
        return 2;
}
int methodB(){
        return 3;
}
int main()
{
        printf("%d\n",methodA() && methodB());
        return 0;
}

 

输出:1

理想情况下短路操作输出:3

结论:c语言中逻辑运算符返回值为0或1,作为短路操作符时,并不能正确地返回结果

 

 

 

 

 

 

 


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter