-2

I'm trying to write in visual c++ to convert a condition text to a simple "if" conditional expression with arithmetic operators, parentheses.

For exemple : text : "(((a+b)>0)or(c==10))and(d!=e))" or "(a>b)xor(c==d)", etc...

we have normally in c++ style :

int a,b,c,d,e;
...
...    
char text[]="(((a+b)>0)or(c==10))and(d!=e))";
if(text_to_if(text)) { .... }
...
...

letters a, b, c, d, e in text correspond with existing integer or float variables.

gsamaras
  • 71,951
  • 46
  • 188
  • 305

1 Answers1

0

Please mind that C++ is not an interpreted language. You can not change code, including if statements, at runtime. If you want runtime code evaluation you could try JavaScript with its eval() function 1.

Further on you won't be able to retrieve variable names from your code (except for debugging purposes).

TIL
  • 25
  • 1
  • 8