diff --git a/du3/program.c b/du3/program.c index 7f441ec..01c16e0 100644 --- a/du3/program.c +++ b/du3/program.c @@ -33,12 +33,14 @@ void process_operations(struct stack* stack) { int could_read = 0; while (fgets(line, sizeof(line), stdin)) { - line[strcspn(line, "\n")] = '\0'; - if (line[0] == '\0') { - printf("no input\n"); - return; - } could_read= 1; + line[strcspn(line, "\n")] = '\0'; + if (line == '\0') + {printf("no input\n"); + return; + + } + if ((strcmp(line, "+") == 0 || strcmp(line, "-") == 0 || strcmp(line, "*") == 0 || strcmp(line, "/") == 0)) { @@ -59,7 +61,7 @@ void process_operations(struct stack* stack) { char *endptr; float val = strtof(line, &endptr); if (endptr == line) { - printf("bad input\n"); + printf("no input\n"); return; } push_stack(stack, val);