From 5a164c3660195111b85cfb5450a7a6f4d45029f3 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 18:25:21 +0100 Subject: [PATCH] Expanded main function with operation handler processing methods --- src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.c b/src/main.c index 4f4b2b5..befd311 100644 --- a/src/main.c +++ b/src/main.c @@ -14,4 +14,17 @@ int main() { } printf("\nPlease enter the first and the second number separated by a space...\n"); + while(fgets(buffer, 100, stdin)) { + buffer[strcspn(buffer, "\n")] = '\0'; + if (strlen(buffer) > 0) { + break; + } + } + + int* result = evaluateInput(buffer, input); + if(result == NULL) { + printf("\nInvalid formatting. Two numbers need to be separated by a space\n"); + return 0; + } + printf("\nResult: %d", *result); } \ No newline at end of file