bool02.c
来自「this is a gcc file, you can download it 」· C语言 代码 · 共 64 行
C
64 行
//980324 bkoz//test for bool and bitwise ands#include <assert.h>void bar ( bool x ) {};void bars ( short x ) {};#if 0int andb(){ bool y; bar ( y ); int blob = ( 27 & int (y) ); return blob; //expect 1 or 0}#endifint andbtrue(){ bool y = true; bar ( y ); int blob = ( 27 & int (y) ); return blob; //expect 1}int andbfalse(){ bool y = false; bar ( y ); int blob = ( 27 & int (y) ); return blob; //expect 0}int andbfalse2(){ bool y = 0; bar ( y ); int blob = ( 27 & int (y) ); return blob; //expect 0}int ands(){ short y = 1; bars ( y ); int blob = ( 27 & int (y) ); return blob; //expect 1}int main() { int tmp;#if 0 tmp = andb(); assert (tmp == 1 || tmp == 0);#endif tmp = andbtrue(); assert (tmp == 1); tmp = andbfalse(); assert (tmp == 0); tmp = andbfalse2(); assert (tmp == 0); tmp = ands(); assert (tmp == 1); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?