linux kernel !! usage

507阅读 0评论2011-09-02 checl1987_EE
分类:LINUX

!! 主要用于在value 为真时候, 返回1。

#include

int main(int argc, char *argv[])
{
/* if test is not eque 0, !! is used to get true value(1) */
int test = 10;

printf("test_1   = %d\n", test);
printf("!test_1  = %d\n", !test);
printf("!!test_1 = %d\n", !!test);

/* if test is 0, !! is not meanful */
int test_2 = 0;

printf("test_2   = %d\n", test_2);
printf("!test_2  = %d\n", !test_2);
printf("!!test_2 = %d\n", !!test_2);

return 0;
}

chechunli@chechunli-PC:~ $ ./test 
test_1   = 10
!test_1  = 0
!!test_1 = 1
test_2   = 0
!test_2  = 1
!!test_2 = 0

上一篇:list_for_each_entry
下一篇:property_get and property_set