符号 ID 而不是实际符号
Symbol id instead of the actual symbol
vector<vector<int>> mapVector(maxX, vector<int>(maxY));
char* mapBuffer = new char[mapString.size() + 1];
...
mapVector[i][j] = mapBuffer[y];
...
mapBuffer[i][j]
包含"#"符号,但在"mapVector[i][j] = mapBuffer[y]
"之后 mapVector[i][j]
contans 编号"35"。为什么它传递的是id而不是符号?
以下是使用 printf 查看数据的方法:
#include <stdio.h>
int main (int argc, char **argv){
char test='#';
printf("test %c %dn", test,test);
return 0;
}
%c 呈现为字符%d 呈现为 int
(以上是C语言,但C的那部分将由C++编译器编译)
因此,在您的代码中,如果您将向量更改为 char 向量,您将不会遇到问题:
vector<vector<char>> mapVector(maxX, vector<char>(maxY));
char* mapBuffer = new char[mapString.size() + 1];
...
mapVector[i][j] = mapBuffer[y];
...
相关文章:
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 将无符号char*转换为std::istream*C++
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- vscode g++链路故障:体系结构x86_64的未定义符号
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 使用gcc从静态链接的文件中查找可选符号
- C++中无符号字符溢出
- 使用无符号字符数组有效存储内存
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- VC++本机单元测试,找不到调试符号
- 为什么我必须在C++中添加一个赋值符号来声明一个数组
- 从函数角度看ID到文件路径的内部与外部映射
- 通过组合不同的类型来创建唯一的id
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- 检查TCHAR数组输入是否为带符号整数C++
- 符号 ID 而不是实际符号
- 使用Win32 API列出存储在资源专用库(DLL)中的消息id和符号名称