マップエントリが行で区切られ、キーと値が「:」で区切られたファイルがあるので、次のようになります。
1 : 1
2 : 2
3 : 3
4 : 4
これを dict という ifstream で開き、次のコードを実行します。
string key, value;
map< string, int > mytest;
while( getline( dict, key, ':' ).good() && getline( dict, value ).good() )
{
mytest[key] = atoi( value.c_str() );
}
これを行うより良い方法はありますか?キーからスペースを削除する getline 機能はありますか? (ブーストなしでこれをやろうとしています。)