I need to create an equation evaluator in c. Purpose is, i have an equation in string(char[]) form like "((2+3)log(165))^2" and need to evalute this in c. i cannot use any external c libraries (i can use math.h).
I need to create an equation evaluator in c. Purpose is, i have an equation in string(char[]) form like "((2+3)log(165))^2" and need to evalute this in c. i cannot use any external c libraries (i can use math.h).
What, you think someone is going to write code for that, just for kicks, eh?
You might want to think again. This is not a free code factory.
Doing this is of only moderate difficulty, but it does take some effort on your part. Or paying a professional the going rate for their time to do it for you, in which case you might want to post here.
Decent programmers don't come all that cheap though.
In the book The C Programming Language by Brian Kernighan and Dennis Ritchie, there is a complete example of a program to evaluate expressions of this sort in RPN-notation. You could use that as a starting point. If you have a function which evaluates RPN expressions, then all that is needed is to convert your input expression into RPN.
For example, the expression you mentioned, pow(((2+3)*log(165)),2) could be written as follows in RPN:
2 3 + 165 log * 2 pow