evaluate a string expression in if statement Linux C/C++

P

PasalicZaharije

If you have only one const (e.g. one number), there is a lot of
functions/class for str->int (or double, or float, or ...) conversion
(like std::strstream).

If it is expression of type 123+12-123/123, you must write some kind of
parser/evaluator (look for conversion of infix <-> sufix form).

Best,
Zaharije Pasalic
 
O

ondra.holub

If you do not want to write parser, you can embed some scripting
language (for example python) in your C/C++ program and evaluate the
expression in this embedded scripting language. Yes, this is overkill,
but on the other hand it is very quick - there is enough to simply
modify first embedding tutorial you find.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top