ok, here is the deal: I have a txt file, as below:
Code:
a
b
c
d
e
f
a.o: a b
b.o: b c d
e.o: e f
something: a.o b.o e.o
and I have to parse through it, and seperate it omitting the ':' and keeping track of some extra stuff. For example a through f, are basic files, but a.o, b.o, e.o, and somehting are targets, and I need to know that.
anyways, the first thing I had to do is count all the basic files and targets, and then read them into a map, that was relatively simple:
Code:
void ReadFile::readIntoMap( MyMap &mapName, string fileName )
{
ifstream inStream3;
inStream3.open( fileName.c_str() ); //open user chosen file
//declaring variables
int i=0; //counter
int vertex=0; //place for all the vertices
string temp; //temp place holder
/*********************************
TESTING
********************************/
cout << endl << "these are the veritces/values in the map: " << endl;
while( !inStream3.eof() && inStream3.good() )
{
getline( inStream3, temp );
if( temp.length() == 1 )
mapName.insert( temp, vertex );
else{
i=temp.find( ':', 0 );
if ( i>0 )
temp.resize( i, ' ' );
else{
i = temp.find( ' ', 0 );
temp.resize( i, ' ' );
}
mapName.insert( temp, vertex );
}
vertex++;
if( vertex > lines )
break;
}
inStream3.close();
}
but now I can not just "chop" off the temp (temp.resize( i, ' ' );) because I need the "stuff" that follows it...any ideas?