Thompsons self duplicating program

Sjoerd Mullender sjoerd at vu44.UUCP
Fri Aug 31 18:49:30 AEST 1984


Jim McKie (mcvax!jim) mentioned a self replicating program he extracted
from 'Some Self-Reproducing Programs' by Theo de Ridder.
I have been able to squeeze out a few more bytes.
Here it is:

char p[]="char p[]=%c%s%c;main(){printf(p,34,p,34,10);}%c";main(){printf(p,34,p,34,10);}

This program is 89 characters.
It can be made shorter if you don't insist on a newline at the end of a
program:

char p[]="char p[]=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}

This one is only 80 characters long.
---
			Sjoerd Mullender
			...!decvax!mcvax!vu44!sjoerd



More information about the Comp.sources.unix mailing list