I'm trying to parse equations like these which only has two values or the square root of a certain value from a text file:
100+100
-100-100
-(100)+(-100)
sqrt(100)
by the minues signs, parenthesis and the operator symbol in the middle and the square root, and i have no idea how to start off...i've got the file part done and the simple calculation parts except that i couldnt get my program to solve the equations in the above.
char *tok = buff;
sscanf(tok,"%lf%c%lf",&num1,&sym,&num2);
that is what have i written for the other basic operations without parenthesis and the minus sign for the second value and it works great for the simple ones. i'm using a switch method to calculate the add,sub,mul and divide but i'm not sure how to properly use the sscanf function (if i am not using it properly) or if there is another way using a function like strtok to properly parse the parenthesis and the minus signs. any kind help?