Self-printing C program

Jeff Jenness jeffj at mcs213j.cs.umr.edu
Mon Sep 17 08:01:48 AEST 1990


In article <38724 at unix.cis.pitt.edu> meyer at unix.cis.pitt.edu (Timothy S. Meyer) writes:
>
>Seems to me I saw a self-printing C program a few years back in CACM or
>Computer magazine, but I can't seem to find it.  Can anyone give me a
>reference for such a program?  (A self-printing program is one that 
>outputs a copy of its own text and is more of a recreational interest I
>think.)
>
>Any help will be appreciated.

Here is an example of what you are looking for:

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

Hope this helps,

-- 
Jeff Jenness
University of Missouri - Rolla
jeffj at cs.umr.edu



More information about the Comp.lang.c mailing list