home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / feoferr.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  71 lines

  1. /***
  2. *feoferr.c - defines feof() and ferror()
  3. *
  4. *       Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Defines feof() (test for end-of-file on a stream) and ferror() (test
  8. *       for error on a stream).
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <stdio.h>
  14.  
  15. /* remove macro definitions for feof() and ferror()
  16.  */
  17. #undef  feof
  18. #undef  ferror
  19.  
  20. /***
  21. *int feof(stream) - test for end-of-file on stream
  22. *
  23. *Purpose:
  24. *       Tests whether or not the given stream is at end-of-file. Normally
  25. *       feof() is a macro, but it must also be available as a true function
  26. *       for ANSI.
  27. *
  28. *Entry:
  29. *       FILE *stream - stream to test
  30. *
  31. *Exit:
  32. *       returns nonzero (_IOEOF to be more precise) if and only if the stream
  33. *       is at end-of-file
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38.  
  39. int __cdecl feof (
  40.         FILE *stream
  41.         )
  42. {
  43.         return( ((stream)->_flag & _IOEOF) );
  44. }
  45.  
  46.  
  47. /***
  48. *int ferror(stream) - test error indicator on stream
  49. *
  50. *Purpose:
  51. *       Tests the error indicator for the given stream. Normally, feof() is
  52. *       a macro, but it must also be available as a true function for ANSI.
  53. *
  54. *Entry:
  55. *       FILE *stream - stream to test
  56. *
  57. *Exit:
  58. *       returns nonzero (_IOERR to be more precise) if and only if the error
  59. *       indicator for the stream is set.
  60. *
  61. *Exceptions:
  62. *
  63. *******************************************************************************/
  64.  
  65. int __cdecl ferror (
  66.         FILE *stream
  67.         )
  68. {
  69.         return( ((stream)->_flag & _IOERR) );
  70. }
  71.