+ 1

String to code

I got a input variable string code = "y = x + 1" Is it possible to use this code like Code() I know this is not the correct way but i want something like that

1st Dec 2019, 7:09 PM
Cat Sauce
Cat Sauce - avatar
1 Answer
+ 1
You'd have to make an interpreter that interprets the string. But this will get big very quickly if you want to add more features, you'll probably get a new language by the time you're done. Instead, you can use a scripting language and embed it into C++. Python Lua Ruby Are probably among the more popular ones. An example with Lua: https://www.youtube.com/watch?v=9OYK10r7iqE
1st Dec 2019, 8:49 PM
Dennis
Dennis - avatar