Path: utzoo!attcan!uunet!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tle.enet.dec.com!daniels From: daniels@tle.enet.dec.com (Bradford R. Daniels) Newsgroups: comp.lang.c Subject: Re: fseek in VAX C Message-ID: <13322@shlump.nac.dec.com> Date: 11 Jul 90 14:28:32 GMT References: <0093978E.33625920@vmsd.csd.mu.edu> Sender: newsdaemon@shlump.nac.dec.com Reply-To: daniels@tle.enet.dec.com (Bradford R. Daniels) Organization: Digital Equipment Corporation Lines: 32 What format is the file? If it's a variable record length file, but the records are all the same size, you should be able to get to the previous by doing: fseek(fp, ftell(fp)-sizeof(record_type)-2,SEEK_SET) (The -2 accounts for the 2-byte record size field.) This work-around is, of course, not supported, but it will get you there. If the record format is fixed length, and the file's record size is the same as sizeof(record_type), you can do: fseek(fp, ftell(fp)-sizeof(record_type),SEEK_SET) Or even just make up an offset as long as it's a multiple of the file's maximum record size. Note that there's a good chance a future release of VAX C will provide a way to position to arbitrary byte offsets in fixed record length files. Arbitrary positioning in variable record length file is a much nastier problem, and one which may never satisfactorily be resolved. Of course, if it is a fixed format file, you can avoid the whole issue by adding "ctx=stm" to your open() statement. Your I/O will be slower, but the Unix emulation is much better (including allowing arbitrary byte positioning). - Brad ----------------------------------------------------------------- Brad Daniels | Digital Equipment Corp. almost DEC Software Devo | definitely wouldn't approve of "VAX C RTL Whipping Boy" | anything I say here...