diff --git a/src/inputHandling.c b/src/inputHandling.c index c8191f1..54ceecf 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -6,11 +6,11 @@ char formulaBuffer[1000]; -void processInput(char* formulaString, int length) { - deleteWhitespace(formulaString, length); +void processInput(char* formStr, int length) { + deleteWhitespace(formStr, length); calc_op temp; - memcpy(formulaBuffer, formulaString, length); - temp.formular = formulaString; + memcpy(formulaBuffer, formStr, length); + temp.formular = formStr; temp.functionsType = detectFunctionOperator(formulaBuffer, 10); if (getNumbers(formulaBuffer, length, &temp) == NULL){ showStruct(&temp); @@ -20,11 +20,11 @@ void processInput(char* formulaString, int length) { } //Leerzeichen löschen -void deleteWhitespace(char* formulaString, int length){ +void deleteWhitespace(char* formStr, int length){ for(int stringPos=0; stringPos < length; stringPos++){ - if((formulaString[stringPos] == ' ') || (formulaString[stringPos] == '\n') || (formulaString[stringPos] == '\r')){ + if((formStr[stringPos] == ' ') || (formStr[stringPos] == '\n') || (formStr[stringPos] == '\r')){ for (int j=stringPos; j < length; j++){ - formulaString[j]=formulaString[j + 1]; + formStr[j]=formStr[j + 1]; } stringPos--; } @@ -32,9 +32,9 @@ void deleteWhitespace(char* formulaString, int length){ } //Einfachste Rechenoperationen lesen -op detectFunctionOperator(char* formulaString, int length){ +op detectFunctionOperator(char* formStr, int length){ for(int stringCount=0; stringCount < length; stringCount++){ - switch (formulaString[stringCount]){ + switch (formStr[stringCount]){ case '+': return opAdd; case '-': return opSub; case '/':case ':': return opDiv; @@ -47,7 +47,7 @@ op detectFunctionOperator(char* formulaString, int length){ } //Zahlen auslesen (+) -char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //processInput sind: string, länge vom String, berechnungsstruct +char* getNumbers(char* formStr, int length, calc_op* formulaRef){ //processInput sind: string, länge vom String, berechnungsstruct // char tmp[length]; char* splitPnt; int numPos = 0; @@ -67,8 +67,8 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces break; default: return NULL; } - // memcpy(tmp, formulaString, length); //string kopiert - char *token = strtok(formulaString, &delimiter); //An der Stelle von dem ersten Plus wird ein NULL (Stringende) gesetzt + // memcpy(tmp, formStr, length); //string kopiert + char *token = strtok(formStr, &delimiter); //An der Stelle von dem ersten Plus wird ein NULL (Stringende) gesetzt while (token != NULL) { formulaRef->inputNumbers[numPos] = atof(token); // String zu double konvertiert numPos++; @@ -84,9 +84,9 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces } } -void showStruct(calc_op* formulaRef){ - printf("\nBerechnung: %s\n", formulaRef->formular); - switch (formulaRef->functionsType) { +void showStruct(calc_op* formRef){ + printf("\nBerechnung: %s\n", formRef->formular); + switch (formRef->functionsType) { case opAdd: printf("Rechenoperation: Addition\n"); break; case opSub: @@ -99,8 +99,8 @@ void showStruct(calc_op* formulaRef){ printf("Fehler bei Auswahl der Rechenoperationen \n"); } printf("Calculation Variables:\n"); - for (int arrayCount = 0; arrayCount < formulaRef->arrayLength; ++arrayCount) { - printf("Array[%i] = %f\n", arrayCount, formulaRef->inputNumbers[arrayCount]); + for (int arrayCount = 0; arrayCount < formRef->arrayLength; ++arrayCount) { + printf("Array[%i] = %f\n", arrayCount, formRef->inputNumbers[arrayCount]); } - printf("Result: %f\n", formulaRef->result); + printf("Result: %f\n", formRef->result); } \ No newline at end of file diff --git a/src/inputHandling.h b/src/inputHandling.h index 9af608f..ca9e2fa 100644 --- a/src/inputHandling.h +++ b/src/inputHandling.h @@ -15,11 +15,11 @@ void* parent; double result; }calc_op; -extern void processInput(char* formulaString, int length); -extern void showStruct(calc_op* formulaRef); -extern void deleteWhitespace(char* formulaString, int length); -extern op detectFunctionOperator(char* formulaString, int length); -extern char* getNumbers(char* formulaString, int length, calc_op* formulaRef); -extern void showStruct(calc_op* formulaRef); +extern void processInput(char* formStr, int length); +extern void showStruct(calc_op* formRef); +extern void deleteWhitespace(char* formStr, int length); +extern op detectFunctionOperator(char* formStr, int length); +extern char* getNumbers(char* formStr, int length, calc_op* formulaRef); +extern void showStruct(calc_op* formRef); #endif // INPUTHANDLING_H