From 0f23ca57c193cabbc1c3ddc2c974867642518f39 Mon Sep 17 00:00:00 2001 From: Sophia Weber Date: Sun, 28 Jan 2024 13:44:37 +0100 Subject: [PATCH] refactoring: change struct names --- src/inputHandling.c | 20 ++++++++++---------- src/inputHandling.h | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/inputHandling.c b/src/inputHandling.c index 69c70ea..06974a3 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -10,12 +10,12 @@ void processInput(char* formulaString, int length) { deleteWhitespace(formulaString, length); calc_op temp; memcpy(formulaBuffer, formulaString, length); - temp.formel = formulaString; - temp.funktionstyp = detectFunctionOperator(formulaBuffer, 10); + temp.formular = formulaString; + temp.functionsType = detectFunctionOperator(formulaBuffer, 10); if (getNumbers(formulaBuffer, length, &temp) == NULL){ showStruct(&temp); } else { - printf("Formular %s not supported", temp.formel); + printf("Formular %s not supported", temp.formular); } } @@ -52,7 +52,7 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces char* splitPnt; int numPos = 0; char delimiter; - switch (formulaRef->funktionstyp) { + switch (formulaRef->functionsType) { case opAdd: delimiter = '+'; break; @@ -70,12 +70,12 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces // 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) { - formulaRef->array[numPos] = atof(token); // String zu double konvertiert + formulaRef->inputNumbers[numPos] = atof(token); // String zu double konvertiert numPos++; splitPnt = token; token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter } - formulaRef->arraylength=numPos; //Länge des Arrays (also zu berechnende Zahlen) gespeichert + formulaRef->arrayLength=numPos; //Länge des Arrays (also zu berechnende Zahlen) gespeichert op type = detectFunctionOperator(splitPnt, strlen(splitPnt) + 1); if (type != opNotSupported && type != opEmpty){ return splitPnt; @@ -85,8 +85,8 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces } void showStruct(calc_op* formulaRef){ - printf("Berechnung: %s\n", formulaRef->formel); - switch (formulaRef->funktionstyp) { + printf("Berechnung: %s\n", formulaRef->formular); + switch (formulaRef->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->array[arrayCount]); + for (int arrayCount = 0; arrayCount < formulaRef->arrayLength; ++arrayCount) { + printf("Array[%i] = %f\n", arrayCount, formulaRef->inputNumbers[arrayCount]); } printf("Result: %f", formulaRef->result); } \ No newline at end of file diff --git a/src/inputHandling.h b/src/inputHandling.h index 3fa35e7..9af608f 100644 --- a/src/inputHandling.h +++ b/src/inputHandling.h @@ -6,10 +6,10 @@ typedef enum{ }op; typedef struct { -op funktionstyp; -char* formel; -double array[10]; -int arraylength; +op functionsType; +char* formular; +double inputNumbers[10]; +int arrayLength; void* child; void* parent; double result;