相关疑难解决方法(0)

1字节整数数据类型

我写了以下代码:

 #include <iostream>
 #include <iomanip>
 #include <stdint.h>

 using namespace std;

 int main()
 {
     uint8_t c;

     cin  >> hex >> c;
     cout << dec << c;

     return 0;
 }
Run Code Online (Sandbox Code Playgroud)

但是当我输入c-hex为12时,输出也是c.我期待着12.后来我了解到:

uint8_t通常是一个typedef unsigned char.所以它实际上读c作ASCII 0x63.

是否有一个1字节的整数,在执行I/O而不是char时表现为整数?

c++ int hex char uint8t

6
推荐指数
1
解决办法
4449
查看次数

标签 统计

c++ ×1

char ×1

hex ×1

int ×1

uint8t ×1