Update cv3/program.c
This commit is contained in:
		
							parent
							
								
									cee902690b
								
							
						
					
					
						commit
						204652d772
					
				| @ -30,17 +30,14 @@ 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); | ||||
| @ -76,13 +73,13 @@ int main() { | ||||
|             exit(EXIT_FAILURE); | ||||
|         } | ||||
| 
 | ||||
|          | ||||
|         print_stack(&mystack); | ||||
|     } | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void push_stack(struct stack* stack, float value) { | ||||
|     assert(stack->size < STACK_SIZE);  | ||||
|     stack->values[stack->size] = value; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user