Parsing a string with numbers (reading a graph's adjacency list)

I've got a problem that I hope you guys can give me a hand...

I've got a file that keeps record of a graph's adjacency list, it's format

is something like:

(#of Vertexes) (#of Edges)

adjacencies for 1st vertex

adjacencies for 2st vertex

adjacencies for 3st vertex

adjacencies for 4st vertex

.... (and so on)

where the labels for vertexes are integers, so I'd like to parse this whole

thing and put it in a structure that would look like:

struct Graph_List {

int V, E;

int **adj;

Quote:

}

My problem is to find an efficient way to do that, something better than

using fgets() to get the lines from the file and then splitting it in the

spaces and using atoi() to convert stuff to integers.

Any suggestions???

Thank you all,

Fernando Jorge

Federal University of Rio de Janeiro

Computer Science Department

Rio de Janeiro, Brazil