[net.lang.c] self reproducing program

randals (11/04/82)

My favorite short self-reproducing (but not too portable) program is this:

main(){char q=34,n=10,*a="main(){char q=34,n=10,*a=%c%s%c;printf(a,q,a,q,n);}%c";printf(a,q,a,q,n);}

This is all one line.  There *must* be a newline at the end, or the C compiler
(usually) barfs.

I can't take credit for this one, but I don't remember where I got it.

Randal L. Schwartz
Tektronix Microcomputer Development Products
Beaverton, Oregon, USA

UUCP:	...!{ucbvax or decvax}!teklabs!tekmdp!randals (ignore return address)
CSNET:	tekmdp!randals @ tektronix
ARPA:	tekmdp!randals.tektronix @ rand-relay