I'm trying to create a program that dynamically creates strings of code, and as C/C++ is a compiled system, it's not possible to use something like eval() (from JavaScript). So, I thought I could create another .cpp file, compile it, and then execute the .exe. Can someone help me with this?
Maybe you need to use system calls. And then you have to consider the problems of portability.
Or , maybe you could include the compiler libraries in your code...but again portability issues.
But witch libraries I should use to do this? I've never used C/C++ to execute a .exe file, neither to compile another .cpp. I'll need an example or, at least, the function calls and library names.
It sounds terribly risky and error-prone. If you give more details I can probably come up with something. What kind of input will the program take and what should its output be?
Then, as it wouldn't work this way, I thought about creating another .cpp file, compile and execute it. It's just a general view of the idea but i think you can get it.
Ah, and the input could be any kind of code in C/C++, like a for, if, scanf, etc.