fgets.c 469 B

123456789101112131415161718192021222324
  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. char line[256];
  8. while (1) {
  9. if (fgets(line, 256, f)) {
  10. fputs(line, stdout);
  11. } else {
  12. puts("EOF");
  13. if (!feof(f)) {
  14. puts("feof() not updated!");
  15. exit(EXIT_FAILURE);
  16. }
  17. break;
  18. }
  19. }
  20. }