Wednesday, August 20, 2008

Quine programs

A “quine” (or “selfrep”) is a computer program which prints its own listing.

complex yet trivial code to print the own source file is

#include
char *p="#include%c%cchar *p=%c%s%c; %c%cint main(){%c%cprintf(p,13,10,34,p,34,13,10,13,10,13,10,13,10); %c%cgetch();%c%c }";

int main(){
printf(p,13,10,34,p,34,13,10,13,10,13,10,13,10);
getch();
}


Lot more about this type of programming in
http://www.madore.org/~david/computers/quine.html