diff --git a/a1/program.c b/a1/program.c index 9ac68c5..c5c54e1 100644 --- a/a1/program.c +++ b/a1/program.c @@ -5,17 +5,12 @@ #include -char* check_math_problem(const char* problem) { - char* result_str = (char*)malloc(10 * sizeof(char)); - if (result_str == NULL) { - fprintf(stderr, "Error with memory\n"); - exit(EXIT_FAILURE); - } - +char* check_math_problem(const char* problem) +{ - //char* copy = strcmp(problem); + //char* copy; char* copy = (char*)malloc((strlen(problem) + 1) * sizeof(char)); - strcpy(copy, problem); + strcpy(copy, problem); if (copy == NULL) { fprintf(stderr, "Error with memory\n"); exit(EXIT_FAILURE); @@ -74,16 +69,16 @@ char* check_math_problem(const char* problem) { free(copy); return "CHYBA"; } - + free(copy); if (fabs(result - res) < 0.01) { - strcpy(result_str, "OK"); + return "OK"; } else { - strcpy(result_str, "ZLE"); + return "ZLE"; } - free(copy); - return result_str; + return "0"; + } int main() {