From 210c9f7357b9f1b2250fc02ab8c22015ba089020 Mon Sep 17 00:00:00 2001 From: Alexander Tarasov Date: Fri, 1 Dec 2023 23:33:01 +0100 Subject: [PATCH] test if file exists --- 01/01.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/01/01.c b/01/01.c index a058f87..9e8cf30 100644 --- a/01/01.c +++ b/01/01.c @@ -92,6 +92,11 @@ int main(int argc, const char* argv[]) { } FILE * f = fopen(argv[1], "r"); + if (f == NULL) { + printf("Error opening file: %s\n", argv[1]); + return 2; + } + char s[100]; int result = 0;