How would you do this better? (file i/o)
ok here is what i'm trying to do. the file format i bring into the program is as follows:
I want to pull each of these into a variable, that is going to be stored into my adjacency list for the graph. This is a problem as i only seem to get the source colon first vertex and first cost for any given line (with my current mehtod) my question is how to loop through the rest of the line in order to catch te rest of my input file lines.. my code is as follows, assuming i open the file to a variable 'in'
Source1 : Vertex1 12 Vertex2 8 Vertex3 9
Source2 : Vertex1 3
Source4 : Vertex1 2 Vertex4 92
now this is just to get the file into the program, i know that i'll need to add my adjacency list code after these, but i can't run without walking first..
while( getline(in, oneLine) )//reads the input file line into a
//temp string called oneLine
string source, colon, dest;
in >> source;//this is the source for any given line
in >> colon;//this is the colon fall through
//I THINK I NEED TO LOOP THIS BUT HOW?
in >> dest;//pulls the first dest value
in >> cost; // pulls the cost value for a given node
}//closes while loop