From 4ae64ebf95b04cd5a209da543870ebc967057d05 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sat, 9 Mar 2024 12:09:57 +0300 Subject: [PATCH] extol.c: add error checking for `fopen` --- c-programming/jokes/extol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/c-programming/jokes/extol.c b/c-programming/jokes/extol.c index 22aa094..5074486 100644 --- a/c-programming/jokes/extol.c +++ b/c-programming/jokes/extol.c @@ -31,7 +31,12 @@ extol (FILE *f) if (f == NULL) { - FILE *fs = fopen ("extol.txt", "a+"); + FILE *fs = fopen (EXTOL_FILE_NAME, "a+"); + if (fs == NULL) + { + perror ("fopen"); + exit (EXIT_FAILURE); + } fseek (fs, 0L, SEEK_END); result = extol (fs); for (result <<= 4, result &= ~15; (result & 15) != 15; result++)