From 425aae56ec65edfb986551d3804aa56d1951664c Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 7 Apr 2024 18:52:01 +0300 Subject: [PATCH] freadln.c: test: add and use macro `YN` for printing booleans --- c-programming/io/freadln.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/c-programming/io/freadln.c b/c-programming/io/freadln.c index f033f8e..c3daf43 100644 --- a/c-programming/io/freadln.c +++ b/c-programming/io/freadln.c @@ -122,6 +122,8 @@ typedef uintmax_t SIZE_T_FORMAT; typedef size_t SIZE_T_FORMAT; # endif +# define YN(boolean) ((boolean) ? "yes" : "no") + int main(void) { // stdin test printf("Type something> "); @@ -162,8 +164,8 @@ int main(void) { perror("freadln"); exit(EXIT_FAILURE); } else if (result == freadln_EOF || feof(f)) { - printf("File: EOF, breaking the loop (returned by function? %d, " - "feof? %d)\n", result == freadln_EOF, !!feof(f)); + printf("File: EOF, breaking the loop (returned by function? %s, " + "feof? %s)\n", YN(result == freadln_EOF), YN(feof(f))); break; } printf("File, line #%d: '%s' (%" PRIuSIZE " characters)\n", i + 1, line,