I'm wondering if i can create a program that reads texts file. In the text file is c++ code ... could that be compiled in the running exe?

So basically you'll have somehting like this in this first file:

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream infile;
infile.open("newtext.txt")
if (infile.fail())
{
cerr << "error.........

....

}


return 0;
}

compile that it runs and reads this:

#include <iostream>

using namespace std;

int main()
{
x = 7;
cout << 7;

return 0;
}

so instead of displaying the contents of that file it would compile it and the resulting window would be 7 rather than displaying the contents of the file?

Cheers

A simple method: Calls a compiler to compile the source files and calls the generated exe file , redirect its stdin, stdout.

This question has already been answered. Start a new discussion instead.