In the following snippet:
Code:
fscanf(fp,"%s %d",&Type,&total_vertex);
printf("In this graph there is a total of %d vertex.\n",total_vertex);
while(!feof(fp)) {
fscanf(fp,"%s %d %s",&Type,&vertex,&condition);
}
while(!feof(fp)) {
fscanf(fp,"%s %d %d",&Type,&v_origem,&v_destino);
}
First you should not be using feof() to control an input loop, this will usually get one extra input. Use your input function to control the loop.
Second since your file has at least 3 different types of data, GRAPH, NODE, EDGE, you should read one complete line, determine what kind of data this line contains. I would read the entire line with
fgets(), then determine what kind of line this is by looking for your GRAPH, NODE, EDGE tags. The following will get one complete line to begin your processing,
Code:
char buffer[1024]; // Use a large input buffer to insure you can get the entire line.
while((fgets( buffer, 1024, inputFile) != NULL)
{
// process the buffer.
Once you have determined what type of data the line contains you can then process each section differently. Your NODE type also seems to have at least two different types of data, data with := and data with "if" statements, that will need to be processed differently.
Jim