在C语言中,! 叹号是啥意思? !! 两个叹号又是啥意思呢? c语言中(感叹号!)是什么意思?

\u5728C\u8bed\u8a00\u4e2d\uff0c\uff01 \u53f9\u53f7\u662f\u5565\u610f\u601d\uff1f !! \u4e24\u4e2a\u53f9\u53f7\u53c8\u662f\u5565\u610f\u601d\u5462\uff1f

\u611f\u53f9\u53f7\u662f\u8fd0\u7b97\u7b26\uff0c\u903b\u8f91\u975e\u3002\u6bd4\u5982\u8bf4\u201c!\u771f\u201d\u4e5f\u5c31\u662f\u5047\u7684\u610f\u601d\u3002
\u4e24\u4e2a!\u662f\u4e3a\u4e86\u628a\u975e0\u503c\u8f6c\u6362\u62101,\u800c0\u503c\u8fd8\u662f0\u3002
\u56e0\u4e3aC\u8bed\u8a00\u4e2d\uff0c\u6240\u4ee5\u975e0\u503c\u90fd\u8868\u793a\u771f\u3002\u6240\u4ee5!\u975e0\u503c
=
0\uff0c\u800c!0
=
1\u3002
\u6240\u4ee5!!\u975e0\u503c
=
1\uff0c\u800c!!0
=
0\u3002
\u6bd4\u5982\uff1ai=5
!i=0
!!i=1

\uff01\u8868\u793a\u903b\u8f91\u975e\uff0c\u662f\u903b\u8f91\u8fd0\u7b97\u7b26\uff0c\u8fd0\u7b97\u5bf9\u8c61\u662f\u771f\u6216\u5047\u3002
\u82e5\u8868\u793aa\u4e0d\u7b49\u4e8e0\uff0c\u5c31\u5199\u6210a!=0\uff1b\u5047\u8bbea\u7b49\u4e8e1\uff0c\u90a3a!=0\uff1b\u5c31\u662f\u771f\u7684\uff0ctrue\u3002
C\u8bed\u8a00\u4e2d\u7684\u7b26\u53f7\u5206\u4e3a10\u7c7b\uff1a\u7b97\u672f\u8fd0\u7b97\u7b26\u3001\u5173\u7cfb\u8fd0\u7b97\u7b26\u3001\u903b\u8f91\u8fd0\u7b97\u7b26\u3001\u4f4d\u64cd\u4f5c\u8fd0\u7b97\u7b26\u3001\u8d4b\u503c\u8fd0\u7b97\u7b26\u3001\u6761\u4ef6\u8fd0\u7b97\u7b26\u3001\u9017\u53f7\u8fd0\u7b97\u7b26\u3001\u6307\u9488\u8fd0\u7b97\u7b26\u3001\u6c42\u5b57\u8282\u6570\u8fd0\u7b97\u7b26\u548c\u7279\u6b8a\u8fd0\u7b97\u7b26\u3002\u5176\u4e2d\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4e8e\u903b\u8f91\u8fd0\u7b97\uff0c\u5305\u62ec\u4e0e(&&)\u3001\u6216(||)\u3001\u975e(!)\u4e09\u79cd\u3002

\u6269\u5c55\u8d44\u6599\uff1a
1\u3001\u7b97\u672f\u8fd0\u7b97\u7b26
\u7528\u4e8e\u5404\u7c7b\u6570\u503c\u8fd0\u7b97\u3002\u5305\u62ec\u52a0(+)\u3001\u51cf(-)\u3001\u4e58(*)\u3001\u9664(/)\u3001\u6c42\u4f59(\u6216\u79f0\u6a21\u8fd0\u7b97\uff0c%)\u3001\u81ea\u589e(++)\u3001\u81ea\u51cf(--)\u5171\u4e03\u79cd\u3002
2\u3001\u5173\u7cfb\u8fd0\u7b97\u7b26
\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5305\u62ec\u5927\u4e8e(>)\u3001\u5c0f\u4e8e(=)\u3001\u5c0f\u4e8e\u7b49\u4e8e(<=)\u548c\u4e0d\u7b49\u4e8e(!=)\u516d\u79cd\u3002
3\u3001\u903b\u8f91\u8fd0\u7b97\u7b26
\u7528\u4e8e\u903b\u8f91\u8fd0\u7b97\u3002\u5305\u62ec\u4e0e(&&)\u3001\u6216(||)\u3001\u975e(!)\u4e09\u79cd\u3002
4\u3001\u4f4d\u64cd\u4f5c\u8fd0\u7b97\u7b26
\u53c2\u4e0e\u8fd0\u7b97\u7684\u91cf\uff0c\u6309\u4e8c\u8fdb\u5236\u4f4d\u8fdb\u884c\u8fd0\u7b97\u3002\u5305\u62ec\u4f4d\u4e0e(&)\u3001\u4f4d\u6216(|)\u3001\u4f4d\u975e(~)\u3001\u4f4d\u5f02\u6216(^)\u3001\u5de6\u79fb(>)\u516d\u79cd\u3002
5\u3001\u8d4b\u503c\u8fd0\u7b97\u7b26
\u7528\u4e8e\u8d4b\u503c\u8fd0\u7b97\uff0c\u5206\u4e3a\u7b80\u5355\u8d4b\u503c(=)\u3001\u590d\u5408\u7b97\u672f\u8d4b\u503c(+=,-=,*=,/=,%=)\u548c\u590d\u5408\u4f4d\u8fd0\u7b97\u8d4b\u503c(&=,|=,^=,>>=,<<=)\u4e09\u7c7b\u5171\u5341\u4e00\u79cd\u3002
6\u3001\u6761\u4ef6\u8fd0\u7b97\u7b26
\u8fd9\u662f\u4e00\u4e2a\u4e09\u76ee\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u6761\u4ef6\u6c42\u503c(?:)\u3002
7\u3001\u9017\u53f7\u8fd0\u7b97\u7b26
\u7528\u4e8e\u628a\u82e5\u5e72\u8868\u8fbe\u5f0f\u7ec4\u5408\u6210\u4e00\u4e2a\u8868\u8fbe\u5f0f(\uff0c)\u3002
8\u3001\u6307\u9488\u8fd0\u7b97\u7b26
\u7528\u4e8e\u53d6\u5185\u5bb9(*)\u548c\u53d6\u5730\u5740(&)\u4e8c\u79cd\u8fd0\u7b97\u3002
9\u3001\u6c42\u5b57\u8282\u6570\u8fd0\u7b97\u7b26
\u7528\u4e8e\u8ba1\u7b97\u6570\u636e\u7c7b\u578b\u6240\u5360\u7684\u5b57\u8282\u6570(sizeof)\u3002
10\u3001\u7279\u6b8a\u8fd0\u7b97\u7b26
\u6709\u62ec\u53f7()\uff0c\u4e0b\u6807[]\uff0c\u6210\u5458(\u2192\uff0c.)\u7b49\u51e0\u79cd\u3002

感叹号是运算符,逻辑非。比如说“!真”也就是假的意思。
两个!是为了把非0值转换成1,而0值还是0。

因为C语言中,所以非0值都表示真。所以!非0值 = 0,而!0 = 1。
所以!!非0值 = 1,而!!0 = 0。
比如:i=5 !i=0 !!i=1

一般不会有两个叹号
一个叹号是非的意思

比如if( a != 5) 就是如果a不等于5

!为 非
!(表达式)
表达式的值 为0

!(表达式)==1
表达式的值 不为0
!(表达式)==0

求反,也即非

扩展阅读:c语言翻译器 ... c语言感叹号用法 ... c语言符号大全表解释 ... c语言中两个感叹号 ... c语言中感叹号a啥意思 ... c语言感叹号加数字 ... 符号暗语大全 ... c语言感叹号是什么 ... c ++中各种符号的意思 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网