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

  1. /***
  2. * ostrptr.cpp - definitions for ostream operator<<(const void*) member function
  3. *
  4. *       Copyright (c) 1991-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Member function definition for ostream operator<<(const void*).
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <internal.h>
  13. #include <stdio.h>
  14. #include <iostream.h>
  15. #pragma hdrstop
  16.  
  17. ostream& ostream::operator<<(const void * ptr)
  18. {
  19. _WINSTATIC char obuffer[12];
  20. _WINSTATIC char fmt[4] = "%p";
  21. _WINSTATIC char leader[4] = "0x";
  22.     if (opfx())
  23.         {
  24.         if (ptr)
  25.             {
  26.             if (x_flags & uppercase)
  27.                 leader[1] = 'X';
  28.             }
  29.         sprintf(obuffer,fmt,ptr);
  30.         writepad(leader,obuffer);
  31.         osfx();
  32.         }
  33.     return *this;
  34. }
  35.