Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. data* vertexes = (data*)malloc(sizeof(data));
  2.  
  3. if (c == 'A')
  4. {
  5. FILE* f;
  6. f = fopen("option_c.txt", "r");
  7.  
  8. if (f == NULL)
  9. {
  10. printf("\n\nThe program couldn't read in the 'option_a.txt' file. The program is going to stop");
  11. return NULL;
  12. }
  13.  
  14. fscanf(f,"%d\t%d\t%lf\n", &vertexes[i].start, &vertexes[i].end, &vertexes[i].distance);
  15. //printf("\n%d\t%d\t%lf", vertexes[0].start, vertexes[0].end, vertexes[0].distance);
  16.  
  17. do
  18. {
  19. if (fscanf(f, "%d\t%d\t%lf", &x, &y, &z)==3)
  20. {
  21. ++i;
  22. vertexes =(data*)realloc(vertexes, (i+1) * sizeof(data));
  23. //debugmalloc_dump();
  24. vertexes[i].start = x;
  25. vertexes[i].end = y;
  26. vertexes[i].distance = z;
  27. //printf("\n%d\t%d\t%lf", x,y,z);
  28. //printf("\n%d\t%d\t%lf\n", vertexes[i].start, vertexes[i].end, vertexes[i].distance);
  29. }
  30.  
  31. c = getc(f);
  32.  
  33. } while (c != EOF);
  34.  
  35. fclose(f);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement