View Full Version : String as equation?
Sep 28, 2010, 10:37 PM
Has anyone had success turning strings into equations?
ie. take a stored string of 2*5+6 and output 16
Sep 29, 2010, 02:29 AM
You'll have to write a parser.
EDIT: This might not be trivial. I googled "c equation parser" and found this (http://www.ubasics.com/simple_c_equation_parser).
Sep 29, 2010, 08:54 AM
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7)
Sep 29, 2010, 09:39 AM
This has been an assignment in CS courses since 1962. I think you'll be able to find some source code online.
expression evaluation code
Sep 29, 2010, 04:33 PM
Thanks for all the suggestions. I'm going to look into storing them as actual values... we'll see how it goes.