Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data* vertexes = (data*)malloc(sizeof(data));
- if (c == 'A')
- {
- FILE* f;
- f = fopen("option_c.txt", "r");
- if (f == NULL)
- {
- printf("\n\nThe program couldn't read in the 'option_a.txt' file. The program is going to stop");
- return NULL;
- }
- fscanf(f,"%d\t%d\t%lf\n", &vertexes[i].start, &vertexes[i].end, &vertexes[i].distance);
- //printf("\n%d\t%d\t%lf", vertexes[0].start, vertexes[0].end, vertexes[0].distance);
- do
- {
- if (fscanf(f, "%d\t%d\t%lf", &x, &y, &z)==3)
- {
- ++i;
- vertexes =(data*)realloc(vertexes, (i+1) * sizeof(data));
- //debugmalloc_dump();
- vertexes[i].start = x;
- vertexes[i].end = y;
- vertexes[i].distance = z;
- //printf("\n%d\t%d\t%lf", x,y,z);
- //printf("\n%d\t%d\t%lf\n", vertexes[i].start, vertexes[i].end, vertexes[i].distance);
- }
- c = getc(f);
- } while (c != EOF);
- fclose(f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement