   map
  I'm having trouble using the map feature, this is how I'm doing it:#include <map>...    get(Input); //Ensures the user enters a word ('Input')    lower(Input); //transforms 'Input' to lowercase   map<std::string, int> Input_int; //creates Input_int as a map    Input_int["north"||"n"] = 0;    Input_int["northeast"||"ne"] = 1;    Input_int["east"||"e"] = 2;    Input_int["southeast"||"se"] = 3; //Maps the word to a number    Input_int["south"||"s"] = 4;    Input_int["southwest"||"sw"] = 5;    Input_int["west"||"w"] = 6;    Input_int["northwest"||"nw"] = 7;    Input_int["up"] = 8;    Input_int["down"] = 9;...First, map<> isn't working. Am I using it wrong? It gives me a bunch of errors, which I will post if you wish.Second, now that I mapped the words to letters, how do I use it? In the sense of, I have 'Input' and 'Input_int', how do I properly use it in a switch()?I'm currently using it like switch(Input_Int), but that doesn't seem right.   
  "north"||"n" is the boolean true, not a string.   ;Quote:Original post by Fruny"north"||"n" is the boolean true, not a string.so ["north"] = 0; ["n"] = 0;?   ;  That would be a way, yes.Quote:Second, now that I mapped the words to letters, how do I use it? In the sense of, I have 'Input' and 'Input_int', how do I properly use it in a switch()?map<string, int>::iterator itor = Input_int.find(Input);if(itor == Input_int.end()){   // word not found   return;}switch(itor->second){case 0:   // ...};  You probaly want std::map instead of just plain map, I'm assuming you didn't put "using namespace" since you declared std::string.Maybe this?switch( Input_int[Input] ){    case Input_int["north"]:  // do north stuff  break;    case Input_int["south"]:  // do south stuff  break;//etc...};Quote:Original post by ScetIf Input is a string try switch( Input_int[Input] ).Thanks, that did it.   ;Quote:Original post by Servant of the LordQuote:Original post by ScetIf Input is a string try switch( Input_int[Input] ).Thanks, that did it.No. That's a bad solution: if Input was not in the map, Input_int[Input] will add it, with 0 as the corresponding value.;Quote:Original post by FrunyNo. That's a bad solution: if Input was not in the map, Input_int[Input] will add it, with 0 as the corresponding value.True, but I figured that was common sense. He should of course check if the map contains Input before executing the switch.Maybe I assumed too much.   ;  So what is the good way to do it? More often then not, input won't be in the map.   ;Quote:Original post by Servant of the LordSo what is the good way to do it? More often then not, input won't be in the map.See Fruny's post that uses find and then checks if the returned iterator is the same as that returned by end.   