diff --git a/du3/program.c b/du3/program.c index 8dac2b5..fd8c1fa 100644 --- a/du3/program.c +++ b/du3/program.c @@ -17,7 +17,8 @@ int main() { int eq_index = 0; int index = 0; while (fgets(buffer, sizeof(buffer), stdin) != NULL) { - if (buffer[0] == '\n') break; + int error = 0; + if (buffer[0] == '\n') break; index = 0; eq_index = 0; int eq_operand_length = 0; @@ -27,6 +28,12 @@ int main() { index++; continue; } + if (isalpha(buffer[index]) && !error) { + error = 1; + strcpy(output[output_length], "CHYBA"); + output_length++; + + } if (isdigit(buffer[index]) || (buffer[index] == '.' && eq_operand_length > 0 && isdigit(buffer[index + 1])) || (buffer[index] == '-' && (eq_operand_length == 0 || strchr("+-*/=", buffer[index - 1])))) { equation[eq_index][eq_operand_length] = buffer[index]; eq_operand_length++; @@ -47,13 +54,13 @@ int main() { equation[eq_index][eq_operand_length] = '\0'; eq_index++; } - float total = 0.0; char last_operator = '+'; int sign = 0; int n_of_signs = 0; char operators[6] = "+-=*/"; - for (int i=0;i