self-printing programs

utzoo!decvax!yale-com!wagar utzoo!decvax!yale-com!wagar
Thu Nov 4 12:14:14 AEST 1982


I resent Lew Mammel's implication that I would submit a self-printing
C program that didn't work.  The original program I posted did not have
a trailing newline; I just didn't make it clear where the program began
and ended.  There is no requirement that C programs end in newlines.

The program I submitted is, I believe, the shortest possible
self-printing C program, given the standard i/o library.  David Sher
(rocheste!sher) was more responsible than I in concocting it.  A
less-ugly self-printing C program, with a new line, follows.  Requiring
a more standard "C style" is fairly irrelevant to the idea of a
self-printing program, so I ignored that aspect.

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

I'm glad I have stirred up enough interest to get people to write some
self-printing programs.  I would like to see some self printing programs
that perform some "useful" task in addition to printing themselves.

					-Steve Wagar





More information about the Comp.lang.c mailing list