Yes, char* is difficult to manipulate, but char* also is a pointer to null terminated string - the basic C/C++ strings primitive type (well know "C" string). A little modification of "The problem is that what's being used as a key are pointers to chars". No the key are pointers to null terminated strings. Now let's see the code. typedef map STRING2INT; // Thank's Mike m["January"]=1; string str="January"; // cout< 012345678901 the next (12) byte is '\0' // |||||||||||| char somearr[] ="MonthJanuary"; char* psomearr = &somearr[5]; // lets take the address of the fifth byte char** ppkey = &psomearr; // let's try indirect cout<. Best regards, Miro
M
miropl
@miropl
Posts
-
map erase issue -
map erase issue... and just one line more. typedef map< char*, int > STRING2INT; instead typedef map STRING2INT; // it's never going to work Miro