Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!news.funet.fi!hydra!klaava!klaava!wirzeniu From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: How to FSEEK previous line of text? Message-ID: <1991May11.162353.683@klaava.Helsinki.FI> Date: 11 May 91 16:23:53 GMT References: <4508.28269613@iccgcc.decnet.ab.com> <1991May11.063436.18318@swsrv1.cirr.com> Sender: news@klaava.Helsinki.FI (Uutis Ankka) Organization: University of Helsinki Lines: 11 In article <1991May11.063436.18318@swsrv1.cirr.com> toma@swsrv1.cirr.com (Tom Armistead) writes: >In a text file, you can generally assume that the lines will have a max length >of BUFSIZ. So, you could seek backward BUFSIZ*2 bytes, read the number of Unless I'm very much mistaken, as far as text streams are concerned, you can't portably hand fseek any other values than 0 and those earlier returned by ftell. You can't do 'fseek(f, -BUFSIZ, SEEK_CUR)', since the values returned by ftell are not guaranteed to be simple byte offsets (such offsets don't work very well for text files in all environments). -- Lars Wirzenius wirzenius@cc.helsinki.fi