|
|
@ -4,11 +4,13 @@ |
|
|
|
|
|
|
|
char a[STRINGL]; |
|
|
|
void deleteWhitespace(); |
|
|
|
op readFunction(char* data, int length); |
|
|
|
|
|
|
|
void input() { |
|
|
|
printf("Geben Sie eine Rechenoperation ein (Bsp.: 1+1):\n"); |
|
|
|
fgets(a, STRINGL, stdin); //fgets statt scanf, holt den kompletten String inkl. Whitespace |
|
|
|
deleteWhitespace(); |
|
|
|
op b = readFunction(a, 10); |
|
|
|
printf("Ihre Berechnung: %s \n", a); |
|
|
|
} |
|
|
|
|
|
|
@ -23,4 +25,16 @@ void deleteWhitespace(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Einfachste Rechenoperationen lesen |
|
|
|
op readFunction(char* data, int length){ |
|
|
|
for(int i=0; i<length; i++){ |
|
|
|
switch (data[i]){ |
|
|
|
case '+': return opAdd; |
|
|
|
case '-': return opSub; |
|
|
|
case '/': return opDiv; |
|
|
|
case '*': return opMult; |
|
|
|
case '^': return opExp; |
|
|
|
} |
|
|
|
} |
|
|
|
return opNotSupported; |
|
|
|
} |