How to FSEEK previous line of text?

Lars Wirzenius wirzeniu at klaava.Helsinki.FI
Sun May 12 02:23:53 AEST 1991


In article <1991May11.063436.18318 at swsrv1.cirr.com> toma at 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 at cc.helsinki.fi



More information about the Comp.lang.c mailing list