Path: utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!gatech!ncar!noao!arizona!naucse!jdc From: jdc@naucse.UUCP (John Campbell) Newsgroups: comp.os.vms Subject: Re: re: ftell & fseek Message-ID: <827@naucse.UUCP> Date: 4 Aug 88 15:14:07 GMT References: <8808031204.AA26428@ucbvax.berkeley.edu> Organization: Northern Arizona University, Flagstaff, AZ Lines: 38 From article <8808031204.AA26428@ucbvax.berkeley.edu>, by LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU): > > I was working on adapting a C program, currently running under UNIX, > to VMS. I had some problems with the use of "ftell" and "fseek" . > After a call to "fseek" and a number 'n' of calls to "fgetc" are done, > the next "ftell" don't return the actual position ( n bytes after the > last "fseek"), but return the position of the last "fseek". I think > that could be some problems into the implementation of "fseek" and > "getc" so that the pointer to the position into the file is not > correctly handled by this functions. > > On VMS, files may be record- or stream-oriented. A record-oriented file, > which is what you get by default, permits seeking only to the beginning of > a record. > > This is fully discussed in the VAX C documentation. > > -- Jerry Jerry has helped me a lot in the past (probably without remembering doing so) and I don't want this comment to be construed as any criticism at all, but... There is a problem with ftell in VMS 'C' which thinking of things as record oriented doesn't intuitively explain. This "feature" has been discussed on the net before--namely an fgets followed by an ftell (which all sounds record-like) won't properly position you to the start of the record you expect unless the file is a stream-lf file. Current solutions include doing an ungetc(fgetc(...)) prior to the ftell. The first time I ran into this I did not feel it was "fully discussed in the VAX C documentation". As always, if you don't like this behavior, please submit an SPR to DEC (I finally got an acknowledgement that they received one of the two I sent in on this). -- John Campbell ...!arizona!naucse!jdc unix? Sure send me a dozen, all different colors.