home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.coherent
- Path: sparky!uunet!munnari.oz.au!penguin!brianw
- From: brianw@philips.oz.au (Brian Wallis)
- Message-ID: <1992Dec20.121928.9460@philips.oz.au>
- Date: Sun, 20 Dec 92 12:19:28 GMT
- Organization: Philips Public Telecommunications Systems, Melbourne, Australia
- Subject: Bug in fseek or fread??
- Lines: 40
-
- The program below when compiled and run on coherent successfully completes the
- second read and returns 4 bytes that are 0. On HP-UX 8.02 (at work) it returns
- 0 from the second read and the 4 bytes are still what they were before (ie the
- buffer hasn't been overritten).
-
- The HP-UX behaviour is what I would expect. Is this a bug? How does one report
- a suspected bug to MWC (is there a mail address at mwc.com for bug reporting).
-
-
- ----
- #include <stdio.h>
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- FILE *fp;
- int i;
- char buf[100];
-
- if((fp=fopen(argv[0],"r")) == NULL){
- perror(argv[0]);
- exit(1);
- }
- i=fread(buf,1,4,fp);
- printf("fread returned %d buf=%02x%02x%02x%02x\n",
- i,buf[0],buf[1],buf[2],buf[3]);
- if(fseek(fp,100000L,SEEK_SET)==-1){
- perror("fseek()");
- exit(1);
- }
- i=fread(buf,1,4,fp);
- printf("fread returned %d buf=%02x%02x%02x%02x\n",
- i,buf[0],buf[1],buf[2],buf[3]);
- }
- --
- -----------------------------------------------------------------
- Brian Wallis <brianw@philips.oz.au> Phone: +61 3 8813576
- Philips Public Telecommunications Systems Fax: +61 3 8813577
- Melbourne, Australia
-