Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. filesizefromfile nie moze zmieniac wskaznika na plik, wiec musisz najpierw zapisac, potem obliczac size
  2. a wiec musi to u Ciebie wygladac tak:
  3. if(f==NULL)
  4. {
  5. return -2;
  6. }
  7. int pozycja = ftell(f); //!
  8. fseek(f,0,SEEK_END);
  9. int wyn=ftell(f);
  10. fseek(f, pozycja, SEEK_SET); // !
  11. fclose(f);
  12. return wyn;
  13.  
  14. filesizefrom path przekombinowane, wystarczy tak:
  15.  
  16. if(fname == NULL)
  17. return -2;
  18. FILE *fp = fopen(fname, "r");
  19. if(fp == NULL) return -1;
  20. fseek(fp, 0, SEEK_END);
  21. int size = ftell(fp);
  22.  
  23. fclose(fp);
  24. return size;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement