Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 +SENDMAIL+2.11; site dcl-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!mcvax!ukc!icdoc!dcl-cs!stephen From: stephen@dcl-cs.UUCP (Stephen J. Muir) Newsgroups: net.sources Subject: Re: shortshort way of reversing the lines in a file Message-ID: <427@dcl-cs.UUCP> Date: Mon, 2-Sep-85 10:26:33 EDT Article-I.D.: dcl-cs.427 Posted: Mon Sep 2 10:26:33 1985 Date-Received: Wed, 4-Sep-85 06:52:30 EDT References: <822@lll-crg.UUCP> Reply-To: stephen@dcl-cs.UUCP (Stephen J. Muir) Followup-To: net.flame Distribution: net Organization: Department of Computing at Lancaster University. Lines: 26 Xpath: icdoc ivax In article <822@lll-crg.UUCP> bandy@lll-crg.UUCP (Andrew Scott Beals) writes: >Recently, some Gentleman from the UK posted a program that reversed >the lines in a file. I figured that I should post this somewhat >shorter solution. At least give me the credit -- see the first line of the body of the article. >#include > >main() { > char foo[BUFSIZ]; > > if(gets(foo) == NULL) return; > main(); > puts(foo); >} This assumes you have enough memory to hold the entire file. Also, you have to read it all -- I wrote the program MAINLY because I wanted a QUICK way to scan backwards. -- UUCP: ...!seismo!mcvax!ukc!dcl-cs!stephen DARPA: stephen%lancs.comp@ucl-cs | Post: University of Lancaster, JANET: stephen@uk.ac.lancs.comp | Department of Computing, Phone: +44 524 65201 Ext. 4599 | Bailrigg, Lancaster, UK. Project:Alvey ECLIPSE Distribution | LA1 4YR