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 {