« What kind of cat are you? | Main | MT Protection test... »
June 27, 2005
Self reproducing programs.
A little bored during my luncheon break, so I thought I'd try my hand at a quine using the C preprocessor.
#define A(B) main(){printf("#define A(B) %s\nA(%s)\n",#A,#A);}
A(main(){printf("#define A(B) %s\nA(%s)\n",#A,#A);})
Running the program produces:
#define A(B) main(){printf("#define A(B) %s\nA(%s)\n",#A,#A);}
A(main(){printf("#define A(B) %s\nA(%s)\n",#A,#A);})
And looking at the Wiki page linked about, it's been done in a neater fashion by someone else. Still, not too bad for 20 minutes messing about.
Scrawled illegibly by Meathe at June 27, 2005 03:38 PM
Comments