Automatically Compiling a File
I have the following code, which opens up a file in CodeBlocks, after having written the program with another program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int main()
{
ofstream myfile ("file.cpp");
myfile << "#include <iostream> \nint main() \n{ \n std::cout << \"This is the new file\" << std::endl; \n return 0; \n} ";
myfile.close();
system("cd C:/Program Files (x86)/CodeBlocks/folder");
system("file.cpp");
return 0;
}
|
How can I then tell CodeBlocks (or MinGW) to compile this file?
Watch the command line that CB uses when it compiles your files:
mingw32-g++.exe -c C:\File.cpp -o C:\File.o
mingw32-g++.exe -o C:\File.exe C:\File.o |
Thank you very much Ramses! :)
Topic archived. No new replies allowed.