|
|
@ -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 { |
|
|
|