[comp.lang.c] is there a c program which outputs itself?

rxg3321@isc.rit.edu (R.X. Getter ) (03/20/91)

hi,
	I am looking for a c program which outputs itself. Has anyone
seen one or heard of one? (No, it cannot read its own source code.)

	thanks,
	Robert Getter

s64421@zeus.usq.EDU.AU (house ron) (03/25/91)

rxg3321@isc.rit.edu (R.X. Getter ) writes:

>hi,
>	I am looking for a c program which outputs itself. Has anyone
>seen one or heard of one? (No, it cannot read its own source code.)

Here you go.  I can't remember where I got it, so I don't know who
to give the credit to.  It wasn't me.

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

--
Regards,

Ron House.   (s64421@zeus.usq.edu.au)
(By post: Info Tech, U.C.S.Q. Toowoomba. Australia. 4350)

flaps@dgp.toronto.edu (Alan J Rosenthal) (03/28/91)

it's also possible to write one which isn't ascii-specific.