【发布时间】:2015-05-25 23:18:11
【问题描述】:
给定以下代码。
#include <cstdint>
#include <iostream>
#include <limits>
int main()
{
int8_t x = 5;
std::cout << x << '\n';
int y = 5;
std::cout << y;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cin.get();
return 0;
}
我的输出是三叶草和5。如果定宽整数是整数,为什么会输出自己数字的ASCII字符符号?
编辑:刚刚发现这种行为只发生在 8 位固定宽度整数上?这是编译器行为吗?
【问题讨论】:
-
std::is_same<std::int8_t, signed char>::value
标签: c++ integer fixed-width