Using setw and left from iomanip
<p>I want to print out the keys and values in a map in a organized table. I am trying to use setw and left but the output is</p>

<pre><code>The  1
hello1
</code></pre>

<p>and I want it to be like</p>

<pre><code>The     1
hello   1
</code></pre>

<p>what i have done so far</p>

<pre><code>// System includes

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include &lt;map&gt;
#include &lt;unordered_map&gt;
#include &lt;fstream&gt;
#include &lt;iomanip&gt;

/************************************************************/
</code></pre>

<p>Local includes</p>

<pre><code>/************************************************************/
// Using declarations

using std::cout;
using std::map;
using std::unordered_map;
using std::string;
using std::cin;
using std::endl;
using std::ifstream;
using std::left;
using std::setw;

/************************************************************/
</code></pre>

<p>Function prototypes/global vars/typedefs</p>

<pre><code>/************************************************************/

int
main (int argc, char* argv[])
{

    //call the wordCount function on the user specified input file
    unordered_map &lt;string,int&gt; exampleMap;
    exampleMap["The"]++;
    exampleMap["hello"]++;

    cout &lt;&lt; left;
    //iterate through the map and print out the elements
    for( unordered_map&lt;string, int&gt;::iterator i=exampleMap.begin(); i!=exampleMap.end(); ++i)
    {
      cout &lt;&lt; setw(5) &lt;&lt; (*i).first &lt;&lt; setw(15) &lt;&lt; (*i).second &lt;&lt; endl;
    }

    return EXIT_SUCCESS;
}
</code></pre>
