This commit is contained in:
Anton Dolozin 2025-10-06 16:12:14 +02:00
parent d1febafb74
commit 208aee0562

View File

@ -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);