[ back to toc ]

os commands in C program source

Date: 2002/02/04 10:34

Q:
Hi Peter!

I want to write a program,and in this program
I want call another c program and compile that.

Can i code operating system's command in my program ,that compile another
C program's source code?

Thanks alot!
"*NAME-DELETED*"
A:
>From C you can call any OS command calling the function system. For
example:

#include <stdlib.h>
main(){
FILE *fCprogram;

fCprogram = fopen("myccode.c","w");
/* here write the other C program */
fclose(fCprogram);

system("cc -o mycode mycode.c");
system("./mycode");
}

Regards,
Peter

[ back to toc ]