Lookup in std::map<string,string> doesn't work

G

gipsy boy

// --
using namespace std;

map<string,string> formMap;
list<string> formParams;

for(list<string>::iterator fit = formParams.begin();
fit!=formParams.end(); fit++) {
cout << "key=" << *fit;
formMap.insert(make_pair(*fit,*(++fit)));
cout << ",value=" << *fit << endl;
}
//--

This outputs:

key=f_action,value=0
key=f_id,value=1
key=f_firstname,value=Britney
key=f_name,value=Spears
key=bday,value=1
key=bmon,value=1
....


But, formMap["f_name"] is an empty string! (like all the entries in
formMap).

What am I doing wrong?
formMap[*formParams.begin()] is an empty string too by the way.

thanks!,
 
G

gipsy boy

gipsy said:
formMap.insert(make_pair(*fit,*(++fit)));

Oops..I suppose this could be a problem, since the order of arguments
isn't explicately defined in standard c++..
sorry, think it'll work without this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top