c - !0 在 C89 中保证为 1?

标签 c language-lawyer c89

我搜索了标准但没有注意到提到的部分。

它只是“0 和 1 之外的任何东西”还是依赖于编译器?

最佳答案

The result of the logical negation operator ! is 0 if the value of its operand compares unequal to 0, 1 if the value of its operand compares equal to 0. The result has type int.

出现在 C89/C90、C99 和 C11 中。

关于c - !0 在 C89 中保证为 1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35440345/

相关文章:

c++ - 减去与同一数组未定义行为无关的两个指针的基本原理是什么?

c++ - 在全局变量的析构函数中初始化 thread_local 变量是否合法?

c - 不需要 'type' 参数且不使用 memcpy 的可移植 C SWAP 宏

C++17 和十进制浮点的当前状态

c - 下溢然后溢出无符号变量不好吗?

c - 用于表示 ANSI (C89/90) C 中的字节的类型?

c - Printf 参数未压入堆栈

c - 我们的 32 位应用程序上的 AppHangXProcB1

c - 从C中的文件中读取特定字符

c - 如何使用 Win32 API 来像控制台一样使用 RichEdit 控件?