You have a couple of problems here. In a map, the template parameters are the [key, value] types, so you have a map with a char key and int value.
Since char is an iteger type, it's perfectly legal to use numeric constants as keys, like you do here:
mymap [1]
. This refers to a map<char, int> element with the char key being the number 1 (which is not the same thing as the character '1').
As it happens, pointers are also integer types, and literal text strings (eg "audio/basic" for instance) are actually
const char*
.
So in the line
mymap [1] = "audio/basic";
you have a map element where the char key is number 1, and the int value is the address of the string constant.
I suspect that what you wanted was a map with an int key and a text string value, like this:
map<int, string> mymap;
mymap [1] = "audio/basic";
As others have pointed out, the for loop is using characters (c='1'; c<'3';) rather than numerical values (c = 1; c< 3;), which will mess things up, since
1 != '1'
.
So with the changed mymap from above, the loop should be like this:
for (int c = 1; c< 3; c++)
{
cout << c;
if (mymap.count(c)>0)
...
.