String parser in C and C #

I have a line, "-(1-cos(R*T))/R" , which I need to evaluate in both C and C #. Is there a library or a quick way to do this? Or do I need to write my own parser?

I also assume that R and T are known and are local variables.

+4
source share
4 answers

There's one in CodeProject, which is definitely worth a look. There's also a 2007 blog post that lists (and benchmarks) numbers, including half a dozen or so, that are free.

+3
source

This is in C #

  private void MyMethod1() { string s = "-(1-cos(R*T))/R"; float R = 1; float T = 1; double doutput =-(1-Math.Cos(R*T))/(R); } 
+2
source

No, in C there is no eval() .

0
source

Regular expression is what you are looking for.

-1
source

All Articles