ungetc_ftell.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <stdio.h>
  2. int main() {
  3. FILE *f = fopen("stdio/ungetc_ftell.c", "r");
  4. printf("%c, %ld\n", getc(f), ftell(f));
  5. printf("%c, %ld\n", getc(f), ftell(f));
  6. printf("%c, %ld\n", getc(f), ftell(f));
  7. ungetc('\n', f);ungetc('d', f);
  8. ungetc('l', f); ungetc('r', f);
  9. ungetc('o', f); ungetc('w', f);
  10. ungetc(' ', f); ungetc('o', f);
  11. ungetc('l', f); ungetc('l', f);
  12. ungetc('e', f); ungetc('h', f);
  13. printf("%c, %ld\n", getc(f), ftell(f));
  14. printf("%c, %ld\n", getc(f), ftell(f));
  15. printf("%c, %ld\n", getc(f), ftell(f));
  16. printf("%c, %ld\n", getc(f), ftell(f));
  17. printf("%c, %ld\n", getc(f), ftell(f));
  18. printf("%c, %ld\n", getc(f), ftell(f));
  19. printf("%c, %ld\n", getc(f), ftell(f));
  20. printf("%c, %ld\n", getc(f), ftell(f));
  21. printf("%c, %ld\n", getc(f), ftell(f));
  22. printf("%c, %ld\n", getc(f), ftell(f));
  23. printf("%c, %ld\n", getc(f), ftell(f));
  24. printf("%c, %ld\n", getc(f), ftell(f));
  25. printf("%c, %ld\n", getc(f), ftell(f));
  26. printf("%c, %ld\n", getc(f), ftell(f));
  27. printf("%c, %ld\n", getc(f), ftell(f));
  28. printf("%c, %ld\n", getc(f), ftell(f));
  29. printf("%c, %ld\n", getc(f), ftell(f));
  30. printf("%c, %ld\n", getc(f), ftell(f));
  31. printf("%c, %ld\n", getc(f), ftell(f));
  32. printf("%c, %ld\n", getc(f), ftell(f));
  33. printf("%c, %ld\n", getc(f), ftell(f));
  34. printf("%c, %ld\n", getc(f), ftell(f));
  35. printf("%c, %ld\n", getc(f), ftell(f));
  36. printf("%c, %ld\n", getc(f), ftell(f));
  37. }