62 char C self repeater (cheater)

David B. Schnepper daves at ios.UUCP
Thu Aug 23 05:49:11 AEST 1984


Here's another repeater, much shorter than the 101 record that
I've seen so far.  I consider this one a cheater, as it is 
possible to break it.

--------------cut line---------------
main(){char b[80],i=open(__FILE__,0);read(i,b,80);printf(b);}
--------------end cut----------------

This program reads in its source and writes it.  Will fail
if the source is not present when run.  Also assumes your
cpp has the "__FILE__" construct (is that standard?).  It
DOES pass the 
  cc file.c
  a.out >tmp
  cmp tmp file.c
test.  
The program can be made shorter if we assume the file name is "y.c"
or somesuch.  (Replace __FILE__).

I **don't** consider this a proper entry in the "shortest c"
contest, as the executable will not always reproduce its source.

Dave Schnepper
ios!daves



More information about the Comp.sources.unix mailing list