翻翻标准,所有不等于0的值转换成bool时都为真,因此(bool)(-2)是true,!(-2) = !(bool)(-2) = false。
(bool)(-2)
true
!(-2) = !(bool)(-2) = false
http://port70.net/~nsz/c/c11/n1570.html#6.3.1.2
程序实验:
!-2表示假,直接退出循环了,C语言中非0即真