How to execute a code from file?

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?
closed account (SECMoG1T)
 
my program reads the c++ code from a file.

I am not aware of this lol, is it possible to make a program using another program from a text file
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.
Topic archived. No new replies allowed.