C++ map problem

This is a discussion on C++ map problem within the C++ Programming forums, part of the General Programming Boards category; Hi,
I have a small problem with a std::map. Whenever I run it in a loop the values only get ...

That's because you insert the same memory block (m1 and m2) multiple times. So you have a map of 3 entries, all of them pointing to the same block of memory, containing "value3" and "key3". You never inserted different memory blocks. Don't use char pointers. Use std::string. std::string will be copied automatically when you make a pair of it and insert it.