efficient strings reading
Hi, I'm building an algorithm for very huge graphs, over several millions of edges (e.g. 5*10^6). A graph is represented in a text file where the edges are in this way:
"string_origin"|"string_destination"|integer
where "string_origin" and "string_destination" are the name of the initial and ending nodes of each edge, respectively (such names can have characters, blanks and numbers). integer is the weight of the edge. Now I read this edges as:
Code:
while (fd.getline(my_string, SIZE)) {
istringstream fichlin(my_string);
fichlin.getline(node1, SIZE, '|');
fichlin.getline(node2, SIZE, '|');
fichlin >> Weight;
//process node1 (char *), node2 (char *) and Weight (int)...
//...
}
My problem is that it is very slow!! In my computer the execution of this loop runs in over 30 sec., so the entry of the input data of the problem supposses more running time than the performance of the underlying algorithm used after.
I would like to know if there's a more efficient way of doing this same operation of strings reading, either in C or in C++ and although it were less clear, so that I could decrease the running time of the program.
Thank you very much in advance!
----------------------------------------------------