By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

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

P: n/a
How can we evaluate a string expression in if statement Linux C/C++

Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
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).

Zaharije Pasalic

Nov 14 '06 #2

P: n/a
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.

Nov 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.