I have a file with entries on the map, separated by a line, and the keys and values ββare separated by the symbol ':' So something like:
one: 1
two: 2
three: 3
four: 4
I open this in an ifstream called dict and run the following code:
string key, value; map< string, int > mytest; while( getline( dict, key, ':' ).good() && getline( dict, value ).good() ) { mytest[key] = atoi( value.c_str() ); }
Is there a better way to do this? Is there any getline functionality that will skip spaces from the key? (I'm trying to do this without promotion.)
source share