Advertisement
AbraaoAllysson

error no arquivo

Jun 5th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. //ARQUIVO = file.txt
  2. /*
  3. 0 A A 1
  4. 0 B C 2
  5. 1 B B 1
  6. 1 C C 2
  7. 2 B B 1
  8. 2 B A 2
  9. */
  10.  
  11. void readCsv() {
  12.  
  13. FILE *fp = fopen("file.txt", "r");
  14. if(!fp) { printf("Erro ao abrir o arquivo.\n"); exit(1); }
  15. char destino[2], proximo[2];
  16. int custo = 0, num = 0, i= 0;
  17.  
  18. while(!feof(fp)) {
  19. fscanf(fp, "%d %s %s %d", &num,destino,proximo,&custo);
  20. printf("%d %s %s %d \n",num, destino, proximo, custo);
  21. i++;
  22. }
  23. fclose(fp);
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement