Chinaunix首页 | 论坛 | 博客
  • 博客访问: 565459
  • 博文数量: 213
  • 博客积分: 6789
  • 博客等级: 准将
  • 技术积分: 1947
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-01 17:11
文章分类

全部博文(213)

文章存档

2012年(9)

2011年(62)

2010年(99)

2009年(43)

分类: LINUX

2011-09-02 14:28:11

!! 主要用于在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

阅读(436) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~