相关疑难解决方法(0)

使用 C++ STL 将 C 样式字符串映射到 int?

stringto 的映射int工作正常。

std::map<std::string, int> // working
Run Code Online (Sandbox Code Playgroud)

但我想将C-style字符串映射到int

例如:

char A[10] = "apple";
map<char*,int> mapp;
mapp[A] = 10;
Run Code Online (Sandbox Code Playgroud)

但是当我尝试访问映射到“apple”的值时,我得到的是一个垃圾值而不是 10。为什么它的行为与std::string?

c++ string dictionary stl

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

标签 统计

c++ ×1

dictionary ×1

stl ×1

string ×1