From command line i am getting file name which i have to compile using gcc. lets say its like this.
./a.out fileToBeCompiled.c
Then how i can compile this file using gcc within my program? lets say main.c for which a.out is being made.
-
You can always call gcc to compile from an shell execution command within your program.
Reference to the system function.
itsaboutcode : Thanks, it work for me.ammoQ : Using system is a bad idea, but if it works for itsaboutcode, it shall be fine with meFrom monksy -
Just exec gcc from within you program.
int main(int argc, char** argv) { execv("/usr/bin/gcc", argv); }From stimms -
Learn how to call
fork(),exec(), andwait(). You probably want to useexecv()for this purpose.From D.Shawley -
./a.out fileToBeCompiled.c && gcc fileToBeCompiled.cIf
./a.outfails (it it returns something other than 0) gcc will not be calledFrom pmg
0 comments:
Post a Comment