Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!dayton!rosevax!umnd-cs!jwabik From: jwabik@umnd-cs.UUCP Newsgroups: comp.lang.c Subject: Help needed -> fseek() and ftell() in VMS VAX C Message-ID: <384@umnd-cs-gw.umnd-cs.UUCP> Date: Wed, 11-Feb-87 17:00:45 EST Article-I.D.: umnd-cs-.384 Posted: Wed Feb 11 17:00:45 1987 Date-Received: Fri, 13-Feb-87 02:28:28 EST Organization: University of Minnesota at Duluth, Computer Science Lines: 53 Keywords: It doesn't do what the manual says .. 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! | ????? / = =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-