From eeb174e1d85af07a96e10a5e65dd1dd6f8c44998 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 22:59:58 +0100 Subject: [PATCH] refactoring: added descriptions for main function --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.c b/src/main.c index c9dee12..56241ed 100644 --- a/src/main.c +++ b/src/main.c @@ -7,9 +7,11 @@ char buffer[100]; int main() { printf("Please enter the id of a specific operation...\n1. addition\n2. subtraction\n3. multiplication\n4. division\n"); + // input for math operation as integer int input; scanf("%d", &input); + // check if operation input is valid if(!checkOperationInput(input)) { printf("Invalid operation id\n"); return 0; @@ -17,6 +19,7 @@ int main() { printf("\nPlease enter the first and the second number separated by a space...\n"); + // loop to enter numbers for calculation while(fgets(buffer, 100, stdin)) { buffer[strcspn(buffer, "\n")] = '\0'; if (strlen(buffer) > 0) { @@ -24,6 +27,7 @@ int main() { } } + // extracting numbers from input int* result = evaluateInput(buffer, input); if(result == NULL) {