471,599 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

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

// --
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!,

--
- gipsy boy
Jul 22 '05 #1
1 6504
gipsy boy wrote:
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

--
gips boy
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Marcelo Pinto | last post: by
19 posts views Thread by Erik Wikström | last post: by
4 posts views Thread by lada77 | last post: by
13 posts views Thread by liujiaping | last post: by
42 posts views Thread by barcaroller | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.