From 5e00520712fa4b0e6493c24e96519eb042009cf9 Mon Sep 17 00:00:00 2001 From: Bohdan Kapliuk Date: Sun, 12 Jan 2025 16:53:00 +0200 Subject: [PATCH] sk1 --- sk1/main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sk1/main.c b/sk1/main.c index efa816e..6c280af 100644 --- a/sk1/main.c +++ b/sk1/main.c @@ -13,21 +13,21 @@ void print_help() { } int main(int argc, char* argv[]) { - int res = 0; + int result = 1; if (argc < 2) { fprintf(stderr, "Chyba: Chybaju argumenty. Pouzite -h pre zobrazenie pomoci.\n"); - res = 0; + result = 0; } if (strcmp(argv[1], "-h") == 0) { print_help(); - res = 0; + result = 0; } if ((strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "-c2") == 0 || strcmp(argv[1], "-d2") == 0) && argc != 4) { fprintf(stderr, "Chyba: Nespravny pocet argumentov. Pouzite -h pre zobrazenie pomoci.\n"); - res = 0; + result = 0; } const char* input_file = argv[2]; @@ -38,30 +38,30 @@ int main(int argc, char* argv[]) { result = compress_1(input_file, output_file); if (result < 0) { fprintf(stderr, "Chyba: Kompresia zlyhala.\n"); - res = 0; + return -1; } } else if (strcmp(argv[1], "-d") == 0) { result = decompress_1(input_file, output_file); if (result < 0) { fprintf(stderr, "Chyba: Dekompresia zlyhala.\n"); - res = 0; + return -1; } } else if (strcmp(argv[1], "-c2") == 0) { result = compress_2(input_file, output_file); if (result < 0) { fprintf(stderr, "Chyba: Kompresia zlyhala.\n"); - res = 0; + return -1; } } else if (strcmp(argv[1], "-d2") == 0) { result = decompress_2(input_file, output_file); if (result < 0) { fprintf(stderr, "Chyba: Dekompresia zlyhala.\n"); - res = 0; + return -1; } } else { fprintf(stderr, "Chyba: Neznámy argument. Použite -h pre zobrazenie pomoci.\n"); - res = 0; + return -1; } - return result; + return 0; } \ No newline at end of file