B
Bart Kevelham
Hi there,
due to some compatibility issues I use char* for strings. I want to use an
STL map where I use these char* as key. But somehow this doesn't seem to
work. The first time I add something to the map, everything works fine. But
the second time, I check if something is already in the map using:
if(mapname.find(aString) != mapname.end()){
//routine for handeling the situation where there already is an object
with the key aString
}
but everytime I want to add a second element to the map with a string I
haven't used, find() still says that there already is an object with the
given key. And if I use a mapname.count(aString) it indeed gives a number
unequal to zero.
I have checked with my debugger that I indeed use another string and not the
same string as the same time. So since I don't use the same string twice, I
don't understand why things don't work....
Is it perhaps that an stl map can't handle char*? Should I convert to
std::string?
Any ideas? I use dev-c++ by the way.
Greetz, Bart.
due to some compatibility issues I use char* for strings. I want to use an
STL map where I use these char* as key. But somehow this doesn't seem to
work. The first time I add something to the map, everything works fine. But
the second time, I check if something is already in the map using:
if(mapname.find(aString) != mapname.end()){
//routine for handeling the situation where there already is an object
with the key aString
}
but everytime I want to add a second element to the map with a string I
haven't used, find() still says that there already is an object with the
given key. And if I use a mapname.count(aString) it indeed gives a number
unequal to zero.
I have checked with my debugger that I indeed use another string and not the
same string as the same time. So since I don't use the same string twice, I
don't understand why things don't work....
Is it perhaps that an stl map can't handle char*? Should I convert to
std::string?
Any ideas? I use dev-c++ by the way.
Greetz, Bart.