using hash_map and string's c_str. i can't use string literals to insert ... please help!!!
Posted on 2004-04-13
The basic problem I'm having is that I need to store hashes as
hashtable[someitem->toString().c_str()] = value;
where the result of .c_str() is lets say, "mykey"
but i need to access them elsewhere using something like
Right now, it doesn't seem to work, because my hash table (i think) stores the address of c_str() instead of a literal (which I want). Anyway to convert string to a string literal :P?
Another example of a problem is like if I have
hashtable[s] = value;
where var = "123"
later i have to get that value out of the hashtable as
It ... doesn't .. work :(!!!!