fseek.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (C) 2016 Jeremiah Orians
  2. * This file is part of M2-Planet.
  3. *
  4. * M2-Planet is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * M2-Planet is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include<stdio.h>
  18. #include <stdlib.h>
  19. int main(int argc, char** argv)
  20. {
  21. if(2 != argc) return 2;
  22. FILE* f = fopen(argv[1], "r");
  23. fseek(f, 15, SEEK_SET);
  24. int c = fgetc(f);
  25. fputc(c, stdout);
  26. fseek(f, -8, SEEK_END);
  27. c = fgetc(f);
  28. fputc(c, stdout);
  29. fseek(f, -19, SEEK_CUR);
  30. c = fgetc(f);
  31. fputc(c, stdout);
  32. fseek(f, 7, SEEK_CUR);
  33. c = fgetc(f);
  34. fputc(c, stdout);
  35. fseek(f, -2, SEEK_END);
  36. c = fgetc(f);
  37. fputc(c, stdout);
  38. fseek(f, 34, SEEK_SET);
  39. c = fgetc(f);
  40. fputc(c, stdout);
  41. fseek(f, 5, SEEK_CUR);
  42. c = fgetc(f);
  43. fputc(c, stdout);
  44. fseek(f, -5, SEEK_CUR);
  45. c = fgetc(f);
  46. fputc(c, stdout);
  47. fseek(f, 6, SEEK_CUR);
  48. c = fgetc(f);
  49. fputc(c, stdout);
  50. fseek(f, -1, SEEK_END);
  51. c = fgetc(f);
  52. fputc(c, stdout);
  53. fclose(f);
  54. return 0;
  55. }