diff --git a/c-programming/io/freadln.c b/c-programming/io/freadln.c index 383a4d3..8a74635 100644 --- a/c-programming/io/freadln.c +++ b/c-programming/io/freadln.c @@ -42,7 +42,7 @@ int freadln(FILE* f, char** output, size_t* length_out) { } int character; - while ((character = fgetc(f)) != EOF + while ((character = fgetc(f)) != EOF && character != EOT /* stop on a newline character: */ && character != '\n') { (*output)[length] = (char) character; diff --git a/c-programming/io/freadln.h b/c-programming/io/freadln.h index c98809e..4db8c98 100644 --- a/c-programming/io/freadln.h +++ b/c-programming/io/freadln.h @@ -12,6 +12,8 @@ #include #include +#define EOT 4 /* end of transmission */ + typedef size_t freadln_length_type; enum freadln_status {