diff --git a/src/inputHandling.c b/src/inputHandling.c index b147ae1..3d1ff4a 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -5,17 +5,17 @@ char data[1000]; -void deleteWhitespace(char* a, int length); -op readFunction(char* data, int length); -char* getNumbers(char* data, int length, calc_op* structure_ref); -void showStruct(calc_op* formula); +void deleteWhitespace(char* formulaString, int length); +op readFunction(char* formulaString, int length); +char* getNumbers(char* formulaString, int length, calc_op* formulaRef); +void showStruct(calc_op* formulaRef); -void input(char* a, int length) { - deleteWhitespace(a, length); +void input(char* formulaString, int length) { + deleteWhitespace(formulaString, length); calc_op temp; - memcpy(data,a,length); - temp.formel = a; + memcpy(data, formulaString, length); + temp.formel = formulaString; temp.funktionstyp = readFunction(data, 10); if (getNumbers(data, length, &temp) == NULL){ showStruct(&temp); @@ -25,20 +25,20 @@ void input(char* a, int length) { } //Leerzeichen löschen -void deleteWhitespace(char* a, int length){ +void deleteWhitespace(char* formulaString, int length){ for(int i=0; ifunktionstyp) { + switch (formulaRef->funktionstyp) { case opAdd: delimiter = '+'; break; @@ -71,15 +71,15 @@ char* getNumbers(char* data, int length, calc_op* structure_ref){ //input sind: break; default: return NULL; } - // memcpy(tmp, data, length); //string kopiert - char *token = strtok(data, &delimiter); //An der Stelle von dem ersten Plus wird ein NULL (Stringende) gesetzt + // memcpy(tmp, formulaString, length); //string kopiert + char *token = strtok(formulaString, &delimiter); //An der Stelle von dem ersten Plus wird ein NULL (Stringende) gesetzt while (token != NULL) { - structure_ref->array[i] = atof(token); // String zu double konvertiert + formulaRef->array[i] = atof(token); // String zu double konvertiert i++; splitPnt = token; token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter } - structure_ref->arraylength=i; //Länge des Arrays (also zu berechnende Zahlen) gespeichert + formulaRef->arraylength=i; //Länge des Arrays (also zu berechnende Zahlen) gespeichert op type = readFunction(splitPnt, strlen(splitPnt)+1); if (type != opNotSupported && type != opEmpty){ return splitPnt; @@ -88,9 +88,9 @@ char* getNumbers(char* data, int length, calc_op* structure_ref){ //input sind: } } -void showStruct(calc_op* formula){ - printf("Berechnung: %s\n", formula->formel); - switch (formula->funktionstyp) { +void showStruct(calc_op* formulaRef){ + printf("Berechnung: %s\n", formulaRef->formel); + switch (formulaRef->funktionstyp) { case opAdd: printf("Rechenoperation: Addition\n"); break; case opSub: @@ -103,8 +103,8 @@ void showStruct(calc_op* formula){ printf("Fehler bei Auswahl der Rechenoperationen \n"); } printf("Calculation Variables:\n"); - for (int i = 0; i < formula->arraylength; ++i) { - printf("Array[%i] = %f\n", i, formula->array[i]); + for (int i = 0; i < formulaRef->arraylength; ++i) { + printf("Array[%i] = %f\n", i, formulaRef->array[i]); } - printf("Result: %f", formula->result); + printf("Result: %f", formulaRef->result); } \ No newline at end of file diff --git a/src/inputHandling.h b/src/inputHandling.h index 9d91f38..337096e 100644 --- a/src/inputHandling.h +++ b/src/inputHandling.h @@ -15,7 +15,7 @@ void* parent; double result; }calc_op; -extern void input(char* a, int length); -extern void showStruct(calc_op* formula); +extern void input(char* formulaString, int length); +extern void showStruct(calc_op* formulaRef); #endif // INPUTHANDLING_H