マップ内のキーと値を整理されたテーブルに出力したいと考えています。setw と left を使用しようとしていますが、出力は
The 1
hello1
そして、私はそれが好きであることを望みます
The 1
hello 1
私が今までやってきたこと
// System includes
#include <iostream>
#include <string>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
/************************************************************/
ローカル インクルード
/************************************************************/
// 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;
/************************************************************/
関数プロトタイプ/グローバル変数/typedef
/************************************************************/
int
main (int argc, char* argv[])
{
//call the wordCount function on the user specified input file
unordered_map <string,int> exampleMap;
exampleMap["The"]++;
exampleMap["hello"]++;
cout << left;
//iterate through the map and print out the elements
for( unordered_map<string, int>::iterator i=exampleMap.begin(); i!=exampleMap.end(); ++i)
{
cout << setw(5) << (*i).first << setw(15) << (*i).second << endl;
}
return EXIT_SUCCESS;
}