From 512a86ed48e3e1cff51ef2002a4e92b68a879492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Mon, 3 Jun 2024 23:10:03 +0500 Subject: [PATCH] Check if file was opened successfuly --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.c b/src/main.c index 2822ade..b8a610b 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,10 @@ int main(int argc, char *argv[]) { return 1; } file = fopen(argv[1],"r"); + if (file == NULL) { + fprintf(stderr,"Unable to open file.\n"); + return 1; + } struct SyntaxElement* code = parse(file); fclose(file); if (code == NULL) {