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.
Just exec gcc from within you program.
int main(int argc, char** argv)
{
execv("/usr/bin/gcc", argv);
}
You can always call gcc to compile from an shell execution command within your program.
Reference to the system function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With