title: initializing a map inside a for loop
body: <p>I am having a problem initializing a map. the goal is to use a string that contains all the keys .e.g "key1 key2 key3" to create entries in the map </p>
  
  <pre><code>map&lt;const char *, int, ltstr &gt; mymap;
  string fortest="a b c";
  istringstream iss(fortest);
  string field;
  //cout&lt;&lt;"transaction name:"&lt;&lt;transactionName&lt;&lt;'\n';
  //cout&lt;&lt;"transaction fields:"&lt;&lt;'\n';
  while(iss&gt;&gt;field)
  {
      mymap[&amp;field[0]]=0;
      cout&lt;&lt;"field name:"&lt;&lt;field&lt;&lt;'\n';
      cout&lt;&lt;mymap.size()&lt;&lt;'\n';
  }
  </code></pre>
  
  <p>But this doesnt work. I am not sure what is the problem</p>