map <int, char*> testmap;
testmap[1] = "123";
testmap[2] = "007";
map<int, char*>::iterator p;
for(p = my_map.begin(); p != my_map.end(); p++) {
int len = strlen(p); // error here, why? thanks
cout << len << endl;
cout << p->first << " : ";
cout << p->second << endl;
}
我在这个谎言上出错了:int len = strlen(p),我想得到数组的长度。如何修复它? 谢谢!
最佳答案
我猜你的意思是
strlen(p->second);
关于C++,迭代器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4864902/