Lets say my program reads the c++ code from a file. Program puts all that code into a string, and calls a compiler to execute it. How it could be done?
Maybe with system commands?
A compiler is not going to be able to read it's input from a string in your program.
You have a couple of choices:
1) Write the string to a file, then pass that file to the compiler via system command.
2) Write the string to a pipe and redirect the compiler's input to read from that pipe.
Uses the system command to invoke the compiler just as if you were typing the compiler command from a command prompt.