diff --git a/src/inputHandling.c b/src/inputHandling.c index e7f7f61..983e521 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -6,12 +6,12 @@ char formulaBuffer[1000]; -void input(char* formulaString, int length) { +void processInput(char* formulaString, int length) { deleteWhitespace(formulaString, length); calc_op temp; memcpy(formulaBuffer, formulaString, length); temp.formel = formulaString; - temp.funktionstyp = readFunction(formulaBuffer, 10); + temp.funktionstyp = detectFunctionOperator(formulaBuffer, 10); if (getNumbers(formulaBuffer, length, &temp) == NULL){ showStruct(&temp); } else { @@ -32,7 +32,7 @@ void deleteWhitespace(char* formulaString, int length){ } //Einfachste Rechenoperationen lesen -op readFunction(char* formulaString, int length){ +op detectFunctionOperator(char* formulaString, int length){ for(int stringCount=0; stringCount < length; stringCount++){ switch (formulaString[stringCount]){ case '+': return opAdd; @@ -47,7 +47,7 @@ op readFunction(char* formulaString, int length){ } //Zahlen auslesen (+) -char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //input sind: string, länge vom String, berechnungsstruct +char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //processInput sind: string, länge vom String, berechnungsstruct // char tmp[length]; char* splitPnt; int numPos = 0; @@ -76,7 +76,7 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //input token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter } formulaRef->arraylength=numPos; //Länge des Arrays (also zu berechnende Zahlen) gespeichert - op type = readFunction(splitPnt, strlen(splitPnt)+1); + op type = detectFunctionOperator(splitPnt, strlen(splitPnt) + 1); if (type != opNotSupported && type != opEmpty){ return splitPnt; } else { diff --git a/src/inputHandling.h b/src/inputHandling.h index 4387a8e..3fa35e7 100644 --- a/src/inputHandling.h +++ b/src/inputHandling.h @@ -15,10 +15,10 @@ void* parent; double result; }calc_op; -extern void input(char* formulaString, int length); +extern void processInput(char* formulaString, int length); extern void showStruct(calc_op* formulaRef); extern void deleteWhitespace(char* formulaString, int length); -extern op readFunction(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); diff --git a/src/main.c b/src/main.c index 23d049e..310d6ea 100644 --- a/src/main.c +++ b/src/main.c @@ -10,5 +10,5 @@ char a[STRINGL] = {0}; void main() { printf("Geben Sie eine Rechenoperation ein (Bsp.: 1+1):\n"); fgets(a, STRINGL, stdin); //fgets statt scanf, holt den kompletten String inkl. Whitespace - input(a, strlen(a)); + processInput(a, strlen(a)); }