Tring
This commit is contained in:
parent
d1febafb74
commit
208aee0562
@ -33,12 +33,14 @@ void process_operations(struct stack* stack) {
|
|||||||
int could_read = 0;
|
int could_read = 0;
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), stdin)) {
|
while (fgets(line, sizeof(line), stdin)) {
|
||||||
line[strcspn(line, "\n")] = '\0';
|
|
||||||
if (line[0] == '\0') {
|
|
||||||
printf("no input\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
could_read= 1;
|
could_read= 1;
|
||||||
|
line[strcspn(line, "\n")] = '\0';
|
||||||
|
if (line == '\0')
|
||||||
|
{printf("no input\n");
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((strcmp(line, "+") == 0 || strcmp(line, "-") == 0 ||
|
if ((strcmp(line, "+") == 0 || strcmp(line, "-") == 0 ||
|
||||||
strcmp(line, "*") == 0 || strcmp(line, "/") == 0)) {
|
strcmp(line, "*") == 0 || strcmp(line, "/") == 0)) {
|
||||||
@ -59,7 +61,7 @@ void process_operations(struct stack* stack) {
|
|||||||
char *endptr;
|
char *endptr;
|
||||||
float val = strtof(line, &endptr);
|
float val = strtof(line, &endptr);
|
||||||
if (endptr == line) {
|
if (endptr == line) {
|
||||||
printf("bad input\n");
|
printf("no input\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
push_stack(stack, val);
|
push_stack(stack, val);
|
||||||
|
Loading…
Reference in New Issue
Block a user