我写了以下代码:
#include <iostream>
#include <iomanip>
#include <stdint.h>
using namespace std;
int main()
{
uint8_t c;
cin >> hex >> c;
cout << dec << c;
return 0;
}
但是当我输入c-hex for 12 - 输出也是c. 我期待 12。后来我了解到:
uint8_t通常是unsigned char. 所以它实际上读c作 ASCII 0x63。
是否有一个 1 字节整数在执行 I/O 时表现为整数而不是字符?