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

  1. /***
  2. * ostrput.cpp - definitions for ostream classes put() and write() functions
  3. *
  4. *       Copyright (c) 1991-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Contains the member function definitions for ostream put() and write().
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <internal.h>
  13. #include <iostream.h>
  14. #pragma hdrstop
  15.  
  16. // note: called inline by char and signed char versions:
  17. ostream& ostream::put(unsigned char c)
  18. {
  19.     if (opfx())
  20.         {
  21.         if (bp->sputc((int)c)==EOF)
  22.             state |= (failbit|badbit);
  23.         osfx();
  24.         }
  25.     return(*this);
  26. }
  27.  
  28. // note: called inline by unsigned char * and signed char * versions:
  29. ostream& ostream::write(const char * s, int n)
  30. {
  31.     if (opfx())
  32.         {
  33. // Note: 'n' treated as unsigned
  34.         if (bp->sputn(s,n)!=n)
  35.             state |= (failbit|badbit);
  36.         osfx();
  37.         }
  38.     return(*this);
  39. }
  40.