If I try the code below, it stores the address as a key and not the value, therefore "the same key is stored twice"
static map<const char *, int> lMap;
const char * msg = "hhhhh";
char *buf = (char *) malloc(6);
strcpy(buf, msg);
lMap.insert(make_pair(buf, 85));
buf = (char *) calloc(5, sizeof (char));
strcpy(buf, msg);
lMap.insert(make_pair(msg, 85));
cout << "size: " << lMap.size() << endl;
map<const char *, int>::const_iterator it2;
for (it2 = lMap.begin(); it2 != lMap.end(); ++it2) {
cout << it2->first << " | " << it2->second << endl;
}
printed result:
size: 2
hhhhh | 85
hhhhh | 85