This code doesnīt work! The value of values[tempS] is always 0.
What is the problem??
Code:#include <map.h> #include <iostream.h> int main(void){ typedef std::map< char *, int, std::less<char *> > mapping; mapping values; values.insert( mapping::value_type("num1", 5 )); values.insert( mapping::value_type("num2", 15 )); char tempS[5]; int tempI; cout << "Insert a string corresponding to a number:\n" ; cin.getline( tempS , 5 ); cout << "Insert an int to be added:\n" ; cin >> tempI; cout << values[tempS] << " + " << tempI; tempI+=values[tempS]; cout << " = " << tempI << endl; /*two cin.get to hold the screen, donīt know better way*/ cin.get(); cin.get(); return 0; }



LinkBack URL
About LinkBacks



CornedBee