mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-13 00:32:08 +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;
|
typedef size_t SIZE_T_FORMAT;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# define YN(boolean) ((boolean) ? "yes" : "no")
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// stdin test
|
// stdin test
|
||||||
printf("Type something> ");
|
printf("Type something> ");
|
||||||
@ -162,8 +164,8 @@ int main(void) {
|
|||||||
perror("freadln");
|
perror("freadln");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if (result == freadln_EOF || feof(f)) {
|
} else if (result == freadln_EOF || feof(f)) {
|
||||||
printf("File: EOF, breaking the loop (returned by function? %d, "
|
printf("File: EOF, breaking the loop (returned by function? %s, "
|
||||||
"feof? %d)\n", result == freadln_EOF, !!feof(f));
|
"feof? %s)\n", YN(result == freadln_EOF), YN(feof(f)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("File, line #%d: '%s' (%" PRIuSIZE " characters)\n", i + 1, line,
|
printf("File, line #%d: '%s' (%" PRIuSIZE " characters)\n", i + 1, line,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user