Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

can anyone guide me on making a c program that can create another c program...?

OpenStudy (anonymous):

Do you mean a program that can code another program - self-reproduction - or that can execute another program?

OpenStudy (anonymous):

not self reproduction {like in virus } but code in same language .... type of ON-DEMAND code production ...

OpenStudy (anonymous):

well u just need to write a file with the code u want in it, its that simple. Maybe u want somehing different, be more specific on what u want. For example a program that u run and create a Hello World program: #include <stdio.h> int main(){ printf("#include \<stdio.h\>\n"); printf("int main()\{\n"); printf("printf\(\"Hello World !\"\)"); print("\}\n"); } compile it, and just do this ./program > helloworld.c and u have created an hello world program from another program. Maybe the printfs are wrong cz i dont now wich symbols requires an \ before. And intead of using a pipe u can just google how to do I/O in C and change a little bit the code to write to a file. And maybe u cant do some of this things i coded here in windows, i have only programmed in linux, so the example its for linux.

OpenStudy (anonymous):

No, I think he wants to create a program in C that can actually code in C by itself, like he/she said, virus type program. It is possible to make, of course this would be more of an advance thing, not necesaritely, because you can start from simple to complex. A compiler can be coded in certain language and can code the same languge, but it needs external operators, like programers. So you want to make a program that runs in C and that can actually code in C, but without ot minimal external operator. In this case you need to code an artificial operator or programer with certan commands before hand and also that be able to write the code and as well as detect sintax errors, code written by others and so on. It depends of what type of program you need, I know the virus type, but it has to be more specific. Like what area? Networking? What should do? What OS? and so on...

OpenStudy (anonymous):

so he wants something like an artificial intelligence? well thats out of my scope, am not an expert in that field. Its still in developement and there arent any awesome advance in a machine that actually acts like a human (none have passed the turing test). Ill wait from him to be more specific and see if i can help

OpenStudy (anonymous):

Yeah, same here, just wait for him to be more specific...

OpenStudy (anonymous):

fairly easy to do , include the stdlib.h and use the system(); to run either another program or use a system command . example using gcc #include<stdlib.h> int main() { system(gcc -o example_program_in_c example_program_in_c.c); system(example_program_in_c); return 0; }

OpenStudy (anonymous):

this is the creation and running part but the code your possibly looking for would be more in the filed of evolutionary programming , so i would look it up and get some ideas before continuing with this

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!