Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utastro.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!ut-sally!utastro!nather From: nather@utastro.UUCP (Ed Nather) Newsgroups: net.bizarre Subject: backwards Message-ID: <470@utastro.UUCP> Date: Fri, 2-Aug-85 10:31:07 EDT Article-I.D.: utastro.470 Posted: Fri Aug 2 10:31:07 1985 Date-Received: Sat, 3-Aug-85 21:03:02 EDT Distribution: net Organization: U. Texas, Astronomy, Austin, TX Lines: 66 >From: jeff (Jeff Brown the Scumbag) >Subject: self-recursion in silly software The following output is the result of running a program on itself: #include <stdio.h> #define BACKSPACE '\010' #define LONG 300 #define LINELENGTH 76 #define FINIS -17 main()          /* to make easy cn line lists */ { char in[LONG], out[LONG]; int i, lin, lout; while ((lin = getline(in)) != FINIS)    {        if(lin > LINELENGTH)    {                lin = LINELENGTH;                in[lin+1] = '\0';                }        for(i = 0; i < LINELENGTH; i++)         out[i] = ' ' ;        lout = LINELENGTH;        if(lin == 0)    { }        else if (lin == 1) out[lout++] = in[0];        else    {                for(i = 0; i <= lin-1; i++)     {                        out[lout++] = in[i];                        out[lout++] = BACKSPACE;                        out[lout++] = BACKSPACE;                        }                }        out[lout++] = '\n';        out[lout] = '\0';        for(i = 0; i < lout; i++) printf("%c",out[i]); } } getline(pn)     /*read the whole buffer, then truncate at ne wline */ char pn[]; { int i; char c; i = 0; while((c = getchar()) != '\n' && c != EOF)       pn[i++] = c ; pn[i] = '\0'; if(c == EOF) i = FINIS; return(i); } ----- Note: If your input file contains tabs the program will not work (I'm working on it, though). You have to pipe it through expand first to get the effect you want. ********************************************************************* -- Ed Nather Astronomy Dept, U of Texas @ Austin {allegra,ihnp4}!{noao,ut-sally}!utastro!nather nather%utastro.UTEXAS@ut-sally.ARPA