fseek.c 436 B

1234567891011121314151617181920
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "test_helpers.h"
  4. int main(void) {
  5. FILE *f = fopen("stdio/stdio.in", "r");
  6. ERROR_IF(fopen, f, == NULL);
  7. int status = fseek(f, 14, SEEK_CUR);
  8. ERROR_IF(fseek, status, == -1);
  9. UNEXP_IF(fseek, status, != 0);
  10. char buffer[256];
  11. printf("%s", fgets(buffer, 256, f));
  12. off_t pos = ftello(f);
  13. ERROR_IF(ftello, pos, == -1);
  14. printf("ftello: %ld\n", pos);
  15. }