Can a program output a copy of itself

ragnarius picture ragnarius · Sep 25, 2009 · Viewed 14.5k times · Source

I think this might be a classic question but I am not aware of an answer. Can a program output a copy of itself, and, if so, is there a short program that does this?

I do not accept the "empty program" as an answer, and I do not accept programs that have access to there own source code. Rather, I am thinking something like this:

int main(int argc, char** argv){ printf("int main(argc, char** argv){ printf...

but I do not know how to continue...

Answer

Cat Plus Plus picture Cat Plus Plus · Sep 25, 2009

It's called a quine, and there's a site that collects them.