Compiling from the command line
I want my program to compile another .cpp file, but I'm having some trouble:
I've searched this board and googled it and came up with the gcc command.
Supposedly, since Dev-C++ uses the gcc compiler (right?) I should be able to compile with:
Code:
gcc myfile.cpp -o myfile
or possibly
Code:
gcc -o myfile.cpp myfile
however, when I include the command in my program:
Code:
system("gcc -o myfile.cpp myfile");
it doesn't work, saying that gcc is "not recognized as an internal or external command, operable program, or batch file."
Should I be trying to use a different directory? Using something other than the system() command?
My other problem is with the system command specifically. I don't know how to get it to accept spaces in the directories. For instance:
Code:
system("c:\\C++ projects\\myfile")
will not execute myfile.exe, it will tell me that "c:\C++ is not recognized as a..." blah blah blah
I tried using the escape character \x20 to add the space, but to no avail. Any ideas there?
Sorry for putting two questions in one post, I probably should have separated them, but I got on a roll typing and here I am.
Thanks in advance for your time.
Decrypt