magic cookies given back by ftell, and used in fseek
Every system needs one
terry at wsccs.UUCP
Sat Jun 4 13:02:37 AEST 1988
In article <129 at lakart.UUCP>, dg at lakart.UUCP (David Goodenough) writes:
> There has been much discussion in this group on the fact that on certain
> systems (VMS I believe), ftell & fseek use magic cookies to tell about
> file position.
No, not really. They work fine on stream files. The problem is
that they return record number on "Implied carriage control" (VMS default)
text files.
> [...] but have the ANSI comittee considered providing some means to convert
> from cookie format to and from character position in file. Come to that
> is such a thing possible?
No. Only the record format, and ANSI doesn't usually say anything about
Digital's file system... they really shouldn't, anyway, as it is none of their
business.
> [...], or is it some other reason.
Yes. It's the "real" storage format and RMS file access modes implied in the
C library.
use:
ungetc( getc( fp));
This will correctly align records after a read so that ftell() doesn't
lie throught it's figurative teeth.
| Terry Lambert UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry |
| @ Century Software OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry |
| SLC, Utah |
| These opinions are not my companies, but if you find them |
| useful, send a $20.00 donation to Brisbane Australia... |
| 'Admit it! You're just harrasing me because of the quote in my signature!' |
More information about the Comp.lang.c
mailing list