C struct数据成员

我在C,Linux工作,遇到以下问题:

struct testing{
uint8_t a;
uint16_t b;
char c;
int8_t d;

};

testing t;

t.a = 1;
t.b = 6;
t.c = 'c';
t.d = 4;
cout << "Value of t.a >>" << t.a << endl;
cout << "Value of t.b >>" << t.b << endl;
cout << "Value of t.c >>" << t.c << endl;
cout << "Value of t.d >>" << t.d << endl;

我的控制台上的输出是:

Value of t.a >>
Value of t.b >>6
Value of t.c >>c
Value of t.d >>

对于int8_t和uint8_t类型,似乎缺少t.a和t.d.为什么会这样?

谢谢.

最佳答案
int8_t和uint8_t类型可能被定义为char和unsigned char.流<<运算符将输出为字符.由于它们分别设置为1和4,它们是控制字符而不是打印字符,因此控制台上不会显示任何内容.尝试将它们设置为65和66('A'和'B'),看看会发生什么. 编辑:要打印出数字而不是字符,您需要将它们转换为适当的类型:

cout << static_cast

相关文章

Linux中的ARP防火墙主要用于防御ARP欺骗攻击,其效果取决于多...
insmod和modprobe加-f参数导致Invalid module format错误 这...
将ArchLinux安装到U盘 几个月前入门Arch的时候上网搜了不少安...
1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...