To test with, I show the key and wait for user input; if the input doesn't match the value, the iterator is stored in the vector.
Expand|Select|Wrap|Line Numbers
- map<string, string> test;
- map<string, string>::iterator it;
- vector<map<string, string>::iterator> bad_input;
- string input;
- test["key 1"] = "value 1";
- test["key 2"] = "value 2";
- test["key 3"] = "value 3";
- for(it = test.begin(); it != test.end(); ++it)
- {
- cout << it->first;
- cin >> input;
- if(it->second != input)
- bad_input.push_back(it);
- }
- for(unsigned i=0; i < bad_input.size(); ++i)
- cout << bad_input[i]->first
- << " "
- << bad_input[i]->second
- << "\n";
Expand|Select|Wrap|Line Numbers
- vector<map<string, string>::iterator>::iterator v_it;
- for(v_it = bad_input.begin(); v_it != bad_input.end(); ++v_it)
- cout << v_it-> ??
TIA