相关疑难解决方法(0)

为什么C或C++标准没有明确地将char定义为signed或unsigned?

int main()
{
    char c = 0xff;
    bool b = 0xff == c;
    // Under most C/C++ compilers' default options, b is FALSE!!!
}
Run Code Online (Sandbox Code Playgroud)

C或C++标准都没有将char指定为有符号或无符号,它是实现定义的.

为什么C/C++标准没有明确地将char定义为有符号或无符号以避免像上述代码那样的危险误用?

c c++ compiler-construction standards types

43
推荐指数
1
解决办法
2874
查看次数

标签 统计

c ×1

c++ ×1

compiler-construction ×1

standards ×1

types ×1