diff --git a/cv3/program.c b/cv3/program.c index 5c21ecc..0ff6571 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -3,7 +3,7 @@ #include #include #include -#define STACK_SIZE 50 +#define STACK_SIZE 10 struct stack { @@ -11,11 +11,16 @@ struct stack int size; }; -void add(struct stack* stack, float num) +int add(struct stack* stack, float num) { + if(stack->size == STACK_SIZE) + { + return 1; + } assert(stack->size < STACK_SIZE); stack->values[stack->size] = num; stack->size++; + return 0; } float getnpop(struct stack* stack) @@ -103,7 +108,12 @@ int main(int argc, char const *argv[]) if(!check_op(buf[0])) { num = atof(buf); - add(&calc_stack, num); + int add_code = add(&calc_stack, num); + if(add_code == 1) + { + printf("full stack\n"); + return 0; + } } else {