diff --git a/cv3/program.c b/cv3/program.c index 37fcc86..a8a5363 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -29,6 +29,10 @@ float getnpop(struct stack* stack) int calculate(struct stack* stack, char operator) { + if(stack->size < 2) + { + return 2; + } float num1 = getnpop(stack); float num2 = getnpop(stack); float res = 0; @@ -108,6 +112,11 @@ int main(int argc, char const *argv[]) printf("division by zero\n"); return 0; } + else if(calculate(&calc_stack, buf[0]) == 2) + { + printf("not enough operands\n"); + return 0; + } } for (int i = 0; i < calc_stack.size; i++) {