home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / aix / 11674 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.1 KB

  1. Path: sparky!uunet!vnet.ibm.com
  2. From: russotto@vnet.ibm.com (Matthew T. Russotto)
  3. Message-ID: <19921118.060506.228@almaden.ibm.com>
  4. Date: Wed, 18 Nov 92 08:58:34 EST
  5. Newsgroups: comp.unix.aix
  6. Subject: Re: Simple EOF problem?
  7. Disclaimer: This posting represents the poster's views, not those of IBM
  8. News-Software: UReply 3.0
  9. References: <BxvzEE.79B@acsu.buffalo.edu>
  10. Lines: 26
  11.  
  12. In <BxvzEE.79B@acsu.buffalo.edu> vidyaranya writes:
  13. >The following piece of code FAILS to detect End of File
  14. >under AIX(i dont know the version currently!) running on
  15. >an IBM PowerServer 970.
  16. >------
  17. >   char buffer[2048];
  18. >   int  i;
  19. >   FILE *fp;
  20. >
  21. >   i=0;
  22. >        while( (buffer[i++]=fgetc(fp))!= EOF )
  23. >         ;
  24. >------
  25. >Exactly same piece of code runs on a SparcStationIPC running
  26. >SunOS 4.1.2 .
  27. >
  28. >What could be the problem?
  29.  
  30. The program is buggy.  EOF is not a char value, but you are comparing
  31. it to one.  Are you using the option which makes 'char's unsigned?
  32. Probably on the SparcStation, it would detect a 0xFF character in the
  33. file as end of file.
  34. Try something like
  35. int tc;
  36.  while ((tc = fgetc(fp))!= EOF)
  37.     buffer[i++] = tc;
  38.