I'd like to know why I have a memory error with this:
The problem appears on char* value = aMap.find(keync)->second
If I put manualy char* value = "key0" it works!!!
using std::map;
map <char*, char*> aMap;
void search(const char* key) {
const int LEN = strlen(key);
char* keync = new char[LEN];
for (int i= 0; i < LEN; i++) {
keync[i] = key[i];
}
char* value = aMap.find(keync)->second;
printf("%s", value);
delete[] keync;
}
int _tmain(int argc, _TCHAR* argv[])
{
a["key0"] = "value0";
search("key0");
return 0;
}