mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-08 18:02:23 +05:30
freadln.c: test: add and use macro YN
for printing booleans
This commit is contained in:
parent
da96289764
commit
425aae56ec
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user