From eb1819276fc3b8b0468424203d37a72365057598 Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 16 Dec 2023 12:22:02 +0100 Subject: [PATCH] ex01: fix: maybe useless --- ex01/src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ex01/src/main.cpp b/ex01/src/main.cpp index 3edc579..ae700bf 100644 --- a/ex01/src/main.cpp +++ b/ex01/src/main.cpp @@ -13,7 +13,7 @@ int multiplication(int a, int b) { return (a * b); } int calculate(std::stack& nums, std::stack& operators) { if (nums.size() < 2 || operators.size() == 0) - return 0; + return 2; int ret; int b = nums.top(); @@ -62,11 +62,14 @@ int main(int ac, char** av) else if (std::strchr("/+-*", av[1][i]) != NULL) { operators.push(av[1][i]); - if (calculate(nums, operators)) + int ret = calculate(nums, operators); + if (ret == 1) { std::cout << "error: division by 0" << std::endl; return 1; } + else if (ret == 2) + break; } else {