Self-replicating program
Self-replicating or self-copying programs are kind of interesting to play with. They are also called Quine. Here is one written in C, by Vlad Taeerov and Rashit Fakhreyev.
main(a)
{
printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);
}
I adjusted it to work on Code::Blocks:
#include <stdio.h>
main(char*a)
{
printf(
a,
34,
a="#include <stdio.h>\nmain(char*a){printf(a,34,a=%c%s%c,34);}",
34);
}
This a prolog version I created:
q :-
listing(q),
write(':-q.').
:-q.
It could have been shorter, but you would have to query ‘q’. This is it:
q:-listing(q).
June 13th, 2012 at 21:43
NNNNNNNNNNNNNNNNadig, can u replicate one urself. I need one,really.