diff --git a/cv3/program.c b/cv3/program.c index 2362ea4..3f668cd 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -30,14 +30,17 @@ int main() { input[strcspn(input, "\n")] = 0; if (strlen(input) == 0) { + printf("no input\n"); break; } if (is_number(input)) { + float value = atof(input); push_stack(&mystack, value); } else if (strlen(input) == 1 && strchr("+-*/", input[0])) { + if (mystack.size < 2) { fprintf(stderr, "Error: Not enough values in stack.\n"); exit(EXIT_FAILURE); @@ -93,8 +96,8 @@ float pop_stack(struct stack* stack) { } void print_stack(struct stack* stack) { + for (int i = 0; i < stack->size; i++) { - printf("%.2f ", stack->values[i]); } printf("\n");