私は次のコードを書きました:
#include <iostream>
#include <iomanip>
#include <stdint.h>
using namespace std;
int main()
{
uint8_t c;
cin >> hex >> c;
cout << dec << c;
return 0;
}
しかし、c
—16進数で12を入力すると、出力も。になりc
ます。私は12を期待していました。後で私はそれを学びました:
uint8_t
通常はのtypedefですunsigned char
。したがって、実際にはc
ASCII0x63として読み取られます。
I / Oを実行している間は整数として動作し、charとしては動作しない1バイト整数はありますか?