输出无序映射内的结构变量
outputting a struct variable that's inside a unordered map
有人知道如何输出无序映射中的结构变量吗?例如,我怎样才能得到dictionary->单词
typedef struct dictionary{
std::string word;
unsigned char hash[20];
std::string hex;
} a_dictionary;
typedef std::unordered_map<std::string, dictionary*> Mymap;
std::unordered_map<std::string, dictionary* >::const_iterator got = c1.find(line);
if(out.is_open())
{
if ( got == c1.end() )
{
out << "????";
}
else
{
out << got->first << " , ";
}
}
}
迭代器的second
成员是指向a_dictionary
结构体的指针,所以就像访问普通结构体指针一样访问它:
out << got->first << " , " << got->second->word;
相关文章:
- 在类构造函数中使用结构变量
- 在类构造函数中定义结构变量的参数
- 为什么我们再次从结构对象创建结构变量?
- 如何从其他结构访问受保护的结构变量
- 指向结构变量的指针未保存到eeprom
- 为什么我的程序没有更改结构变量中的值?
- 在 CPP 中初始化 typedef 结构变量
- 带有大结构变量的 CUDA 内核函数给出了错误的结果
- 有没有办法初始化不涉及编写构造函数的新结构变量?
- 结构变量查询
- 在结构声明的分号之前声明的结构变量是否为全局变量
- C++ 如何访问指针的结构变量
- 使用指向结构变量成员的指针访问该结构的成员的地址
- 为什么在 sizeof() 函数中与 * 运算符一起使用和不使用 * 运算符时,指向结构变量的指针大小会有所不同?
- 如何在类别内的类中访问类中的结构变量
- 尝试使用文本文件初始化多个结构变量
- 从类对象到结构变量的 memcpy
- C++结构变量初始化时出现问题
- 如何在 C++ 中使用带有类/结构变量的列表
- 动态数组添加元素而不创建结构变量/对象