设置一个字节等于int和cout
Setting a byte equal to an int and cout
所以我理解c++将字节定义为类型定义的unsigned char。但我不能完全理解为什么,在将字节变量设置为int后,它被视为笑脸…
#include <iostream>
#include <Windows.h>
using namespace std;
int main(){
int x = 1;
byte y = x;
cout << y;
}
我相信这有一个简单的解释,但我似乎找不到它。unicode或UTF8的第一个字符是否设置为笑脸? 您一定是在使用Windows。代码为1
的字符是code Page 437中的笑脸,命令窗口使用的笑脸。代码点0
到31
不对应Unicode中的可打印字符。
是的,byte
通常定义为unsigned char
。当您将char
变量(有符号或无符号)发送给cout
时,它输出一个字符而不是一个数字。
相关文章:
- 为什么在全局范围内使用"extern int a"似乎不行?
- int(c) 和 c-'0' 之间的区别。C++
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- std::cout输出int时出现编译错误
- 当我们声明 cin 为 int 并从 cin 中获取输入并在 cout 中打印 cin 时会发生什么?
- 打印一个带有静态 int 的函数,有一个 std::cout 和多个 std::cout 有什么区别?
- 为什么printf和cout为此无符号int提供了不同的输出
- cout vector<vector<int>>更简洁
- C++。为什么 std::cout << char + int 打印 int 值?
- typedef int -> 整数。我可以在 c++ 中执行 cout-> 打印吗?
- 如何使用cout正确打印long long int类型
- 设置一个字节等于int和cout
- 如何显示/打印字符串对象?cout & lt; & lt;Int工作,count <<字符串
- 如何打印 map<string、map<int、int>> to cout 的内容?
- 三元运算符中的 Cout 字符串和 int
- 将 Object int 数据成员转换为浮点数并划分会将奇怪的数据 cout 附加到控制台
- 为什么 MSVC 不针对 char 或 const char* 优化 cout,但它为 int 优化?
- std::cout for map<string, int>