diff --git a/src/inputHandling.c b/src/inputHandling.c index e539c60..867402b 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -5,17 +5,21 @@ char formulaBuffer[1000]; +calc_op* mainCalc = NULL; void processInput(char* formStr, int len) { deleteWhitespace(formStr, len); - calc_op temp; + if (mainCalc!=NULL){ + free(mainCalc); + } + mainCalc = malloc(sizeof(calc_op)); memcpy(formulaBuffer, formStr, len); - temp.formular = formStr; - temp.functionsType = detectFunctionOperator(formulaBuffer, 10); - if (getNumbers(formulaBuffer, len, &temp) == NULL){ - showStruct(&temp); + mainCalc->formular = formStr; + mainCalc->functionsType = detectFunctionOperator(formulaBuffer, 10); + if (getNumbers(formulaBuffer, len, mainCalc) == NULL){ + showStruct(mainCalc); } else { - printf("Formular %s not supported", temp.formular); + printf("Formular %s not supported", mainCalc->formular); } }