home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / coherent / 6363 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.4 KB  |  50 lines

  1. Newsgroups: comp.os.coherent
  2. Path: sparky!uunet!munnari.oz.au!penguin!brianw
  3. From: brianw@philips.oz.au (Brian Wallis)
  4. Message-ID: <1992Dec20.121928.9460@philips.oz.au>
  5. Date: Sun, 20 Dec 92 12:19:28 GMT
  6. Organization: Philips Public Telecommunications Systems, Melbourne, Australia
  7. Subject: Bug in fseek or fread??
  8. Lines: 40
  9.  
  10. The program below when compiled and run on coherent successfully completes the
  11. second read and returns 4 bytes that are 0. On HP-UX 8.02 (at work) it returns
  12. 0 from the second read and the 4 bytes are still what they were before (ie the
  13. buffer hasn't been overritten).
  14.  
  15. The HP-UX behaviour is what I would expect. Is this a bug? How does one report
  16. a suspected bug to MWC (is there a mail address at mwc.com for bug reporting).
  17.  
  18.  
  19. ----
  20. #include <stdio.h>
  21.  
  22. main(argc,argv)
  23.   int argc;
  24.   char *argv[];
  25. {
  26.   FILE *fp;
  27.   int i;
  28.   char buf[100];
  29.  
  30.   if((fp=fopen(argv[0],"r")) == NULL){
  31.     perror(argv[0]);
  32.     exit(1);
  33.   }
  34.   i=fread(buf,1,4,fp);
  35.   printf("fread returned %d buf=%02x%02x%02x%02x\n",
  36.     i,buf[0],buf[1],buf[2],buf[3]);
  37.   if(fseek(fp,100000L,SEEK_SET)==-1){
  38.     perror("fseek()");
  39.     exit(1);
  40.   }
  41.   i=fread(buf,1,4,fp);
  42.   printf("fread returned %d buf=%02x%02x%02x%02x\n",
  43.     i,buf[0],buf[1],buf[2],buf[3]);
  44. }
  45. -- 
  46. -----------------------------------------------------------------
  47. Brian Wallis <brianw@philips.oz.au>         Phone: +61 3 8813576
  48. Philips Public Telecommunications Systems      Fax: +61 3 8813577
  49. Melbourne, Australia
  50.