Help needed -> fseek() and ftell() in VMS VAX C
jwabik at umnd-cs.UUCP
jwabik at umnd-cs.UUCP
Thu Feb 12 08:00:45 AEST 1987
I'm trying to fseek my way around a large (1.5MB) file using VAX VMS C,
and am having absolutely NO LUCK.
Background:
I developed software on UNIX to does what I need. The UNIX code
works just fine (and MUCH faster) on the UNIX box. I moved the file
to VMS, made the few cosmetic changes (like pathnames, etc..)
required to compile. No problem. Execution, on the other hand ..
After much grieving, I've come to the conclusion that fseek() and
ftell() don't work the same (if at all!) on VMS as they do on UNIX,
even though the VMS C manual says, "Functionally Equivalent".
Precise Problem Statement:
1) File is opened properly.
2) I've converted LONG ftell variables from UNIX to INT
ftell variables for VMS. I've followed other instructions
in the manual as well.
3) fseek(fp,n,0) does NOT bring me to byte n in the file. If
I do something like:
for (i=0; i<512; i++) printf("%c",getc(fp));
after the fseek, in 95% of the cases I end up with nulls
or blanks printed -- almost as if I fseeked to before BOF
or to after EOF. In the other 5% of the cases I end up with
data from the file, but data that is clearly not even
reasonablly close to n in fp. A ftell(fp) directly
following this loop always returns a BIZARRE value like
(n+x), where x is in the range of 100000..300000, or -n.
I've been playing with this problem for a few weeks -- I've
tried every other type of reading fp (fscanf, fgets, etc..),
and numerous other things that I've long since forgotten..
Just when I have a method that appears to work in a test
program, it fails in the real code..
Help!!! 8^)
Is there a limit to N in fseek(fp,N,0)? (Aside from the limits
of the 32 bit integer.) What would cause a large ftell() skip
by reading 512 bytes? (large > 100000) HOW CAN I MAKE THIS
TO WORK? Might this be a compiler bug? Has anyone else experienced
this VMS snafoo?
Thanks in advance!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Jeff Wabik, UMD Computing Services. | ihnp4 \ =
= University of Minnesota, Duluth 55812| umn-cs!umnd-cs!jwabik -
- "I feel fine." -Spock. Boo. Hiss! | ????? / =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
More information about the Comp.lang.c
mailing list