A Self-Printing C Program

utzoo!decvax!harpo!ihps3!ihuxe!aark utzoo!decvax!harpo!ihps3!ihuxe!aark
Wed Nov 3 16:53:33 AEST 1982

Since I haven't seen any rules for self-printing C programs
other than the implicit one that they should print out their
own source, how about the following (not necessarily the
shortest possible):

	main ()
	system ( "cat /e2/aark/bin/source/selfprint.c" );

where the above text is, of course, stored in the file
/e2/aark/bin/source/selfprint.c.  This works on ihuxe,
which runs USG 4.0 UN*X.

No doubt, since this seems too simple, this violates some
as-yet-unstated rules for self-printing C programs.

Alan R. Kaminsky
Bell Laboratories, Naperville, IL

More information about the Comp.lang.c mailing list