我把一个值存到map里,可是取出来的时候是乱码,具体代码如下:
map<long,string>::iterator it1 = m_contCallidUcid.find(id);
if (it1 != m_contCallidUcid.end())
{
value = it1->second;
}
打出来value的值发现时乱码,我调试到程序里,发现map里是有值得,单it1里的值和map中的值不一样,it1中的第一个值不是map的key,而且第二个值显示错误的指针,map里的值是正常的,我想问问怎么样才能取到正常的值。
map<long,string>::iterator it1 = m_contCallidUcid.find(id);
if (it1 != m_contCallidUcid.end())
{
value = it1->second;
}
打出来value的值发现时乱码,我调试到程序里,发现map里是有值得,单it1里的值和map中的值不一样,it1中的第一个值不是map的key,而且第二个值显示错误的指针,map里的值是正常的,我想问问怎么样才能取到正常的值。
解决方案 »
- 谁在看《windows核心编程》第五版,问个问题
- 运行共享文件夹里的程序,是否会占用网络资源?
- DirectInput怎样用来实时监控键盘输入???
- 有直接的函数可以显示内存中的图像吗?
- 对于edit框(multiline),如果它显示了多行,开始的时候光标位于最前位置,我如何通过程序来使光标移动到最后一个字符处(最后一个字符的后
- 关于CComboBox控件的问题?(Up有分)
- 进程?????? 请帮忙啊!(在线等!)
- 各位大虾,帮帮忙吧,在windows2000平台上通过vc++编程怎么才能给某一个文档加上摘要信息?
- 如何实现用户的手写数字图象?
- 请教怎样辨别是wav还是mp3文件?
- IOCP中WSASend投递成功但GetQueuedCompletionStatus不返回的证据
- 游戏截图的问题,在线等高手。。。
typedef map<long,string> mymapmymap[1] = "123213";
mymap[id]直接就是second的值啊
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
map<long, string> MAP;
MAP.insert(make_pair<long, string>(1, "AA"));
MAP.insert(make_pair<long, string>(2, "BB"));
MAP.insert(make_pair<long, string>(3, "CC"));
map<long, string>::iterator it = MAP.find(2);
if(it != MAP.end())
{
cout<<it->second<<endl;
}
return 0;
}
谢谢一楼,我以后有机会一定尝试一下你的方法