int main() { char c = 0xff; bool b = 0xff == c; // Under most C/C++ compilers' default options, b is FALSE!!! }
C或C++标准都没有将char指定为有符号或无符号,它是实现定义的.
为什么C/C++标准没有明确地将char定义为有符号或无符号以避免像上述代码那样的危险误用?
c c++ compiler-construction standards types
c ×1
c++ ×1
compiler-construction ×1
standards ×1
types ×1