Do I need to highlight a pair if I insert it into a card from another area?
#include <iostream> #include <string> #include <unordered_map> #include <utility> using namespace std; void parseInput(int argc, char *argv[], unordered_map<string, string>* inputs); int main(int argc, char *argv[]) { unordered_map<string, string>* inputs = new unordered_map<string, string>; parseInput(argc, argv, inputs); for(auto& it : *inputs){ cout << "Key: " << it.first << " Value: " << it.second << endl; } return 0; } void parseInput(int argc, char *argv[], unordered_map<string, string>* inputs) { int i; for(i=1; i<argc; i++){ char *arg = argv[i]; string param = string(arg); long pos = param.find_first_of("="); if(pos != string::npos){ string key = param.substr(0, pos); string value = param.substr(pos+1, param.length()-pos); inputs->insert( make_pair(key, value) );//what happens when this goes out of scope } } for(auto& it : *inputs){ cout << "Key: " << it.first << " Value: " << it.second << endl; } }
source share