|
@ -2,25 +2,22 @@ |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#define STRINGL 200 |
|
|
|
|
|
|
|
|
|
|
|
char a[STRINGL]; |
|
|
|
|
|
void deleteWhitespace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char data[1000]; |
|
|
|
|
|
void deleteWhitespace(char* a, int length); |
|
|
op readFunction(char* data, int length); |
|
|
op readFunction(char* data, int length); |
|
|
char* getnumbers(char* data, int length, calc_op* structure_ref); |
|
|
char* getnumbers(char* data, int length, calc_op* structure_ref); |
|
|
void printstruct(calc_op* formula); |
|
|
void printstruct(calc_op* formula); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
void input(char* a, int length) { |
|
|
|
|
|
deleteWhitespace(a, length); |
|
|
calc_op temp; |
|
|
calc_op temp; |
|
|
char data[STRINGL]; |
|
|
|
|
|
memcpy(data,a,STRINGL); |
|
|
|
|
|
|
|
|
memcpy(data,a,length); |
|
|
temp.formel = a; |
|
|
temp.formel = a; |
|
|
temp.funktionstyp = readFunction(data, 10); |
|
|
temp.funktionstyp = readFunction(data, 10); |
|
|
if (getnumbers(data,STRINGL, &temp) == NULL){ |
|
|
|
|
|
|
|
|
if (getnumbers(data,length, &temp) == NULL){ |
|
|
printstruct(&temp); |
|
|
printstruct(&temp); |
|
|
} else { |
|
|
} else { |
|
|
printf("Formular %s not supported", temp.formel); |
|
|
printf("Formular %s not supported", temp.formel); |
|
@ -28,10 +25,10 @@ void input() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Leerzeichen löschen |
|
|
//Leerzeichen löschen |
|
|
void deleteWhitespace(){ |
|
|
|
|
|
for(int i=0; i<STRINGL; i++){ |
|
|
|
|
|
|
|
|
void deleteWhitespace(char* a, int length){ |
|
|
|
|
|
for(int i=0; i<length; i++){ |
|
|
if((a[i]==' ')||(a[i]=='\n')||(a[i]=='\r')){ |
|
|
if((a[i]==' ')||(a[i]=='\n')||(a[i]=='\r')){ |
|
|
for (int j=i; j<STRINGL; j++){ |
|
|
|
|
|
|
|
|
for (int j=i; j<length; j++){ |
|
|
a[j]=a[j+1]; |
|
|
a[j]=a[j+1]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|