ANSI draft - seeking to eof

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Sat Nov 30 14:29:00 AEST 1985


> The latest (November 11) draft from X3J11 says this about fseek():
> 
> 	int fseek (FILE *stream, long offset, int ptrname)
> 	
> 	A binary stream need not meaningfully support fseek
> 	calls with a ptrname value of SEEK_END.
> 
> 	For a text stream, either offset must be zero, or
> 	offset must be a value returned by an earlier call
> 	to ftell on the same stream and ptrname must be 
> 	SEEK_SET.			
> 				[X3J11/85-138, page 109]
> 
> Does this really mean that there's no guaranteed way to seek to the end of
> either a text or a binary stream in ANSI C (when such a beast exists)?

It says you can seek to the end of a text stream but not a binary
stream.  This is interesting; one wonders what systems they had
in mind that can do the one but not the other.

By the way, UNIX I/O is meant to qualify as "text stream".  There
was a problem in the wording that we turned up in P1003 (apparently
would require all UNIX files to end with a newline byte); I don't
know whether X3J11 has fixed this by now, but I sure hope so.



More information about the Comp.lang.c mailing list