From a2601eb15e9fd770ad4857aefd50f1590f4871e6 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Fri, 27 Sep 2024 11:05:41 +0300 Subject: [PATCH] allow for dynamic detection of error-marked values during error printouts --- src/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 5a6fefe..1c42bde 100644 --- a/src/main.c +++ b/src/main.c @@ -139,11 +139,17 @@ print_error_message(char** argv, { puts("[Error] Incorrect CLI argument input."); - if (error_code & 0x1) - print_argument_error(argv, argc, 1); + int current_argument_position = 1; + int temp_error_code = error_code; - if (error_code & 0x2) - print_argument_error(argv, argc, 2); + while (temp_error_code) + { + if (temp_error_code & 0x1) + print_argument_error(argv, argc, current_argument_position); + + temp_error_code >>= 1; + current_argument_position++; + } } int @@ -176,5 +182,3 @@ main(int argc, return 0; } - -