1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-12-26 11:30:03 +05:30

freadln.c: improve the test, make last TODO optional

This commit is contained in:
Intel A80486DX2-66 2024-03-10 14:47:41 +03:00
parent 1a69cfa4ad
commit d7be00df1f
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -10,7 +10,7 @@
* TODO: Figure out potential problems
* TODO: Add 'flushing' of STDIN (while there are characters, read them) before
* the input reading loop to avoid input queues
* FIXME: Handle EOF in a special way to indicate EOF
* [optional] TODO: Handle EOF in a special way to indicate EOF
*/
#include "freadln.h"
@ -93,11 +93,14 @@ int main(void) {
exit(EXIT_FAILURE);
}
f = new_f;
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 4; i++) {
size_t line_length;
if (freadln(f, &line, &line_length) != freadln_OK) {
perror("freadln");
exit(EXIT_FAILURE);
} else if (feof(f)) {
printf("File: EOF, breaking the loop\n");
break;
}
printf("File, line #%d: '%s' (%zu characters)\n", i + 1, line,
line_length);