home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Windows Gam…ming Gurus (2nd Edition)
/
Disc2.iso
/
vc98
/
crt
/
src
/
ostrint.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-06-17
|
1KB
|
53 lines
/***
* ostrint.cpp - definitions for ostream class operator<<(int) member functions
*
* Copyright (c) 1991-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Contains the member function definitions for ostream operator<<(int).
*
*******************************************************************************/
#include <cruntime.h>
#include <internal.h>
#include <stdio.h>
#include <iostream.h>
#pragma hdrstop
ostream& ostream::operator<<(int n)
{
_WINSTATIC char obuffer[12];
_WINSTATIC char fmt[4] = "%d";
_WINSTATIC char leader[4] = "\0\0";
if (opfx()) {
if (n)
{
if (x_flags & (hex|oct))
{
if (x_flags & hex)
{
if (x_flags & uppercase)
fmt[1] = 'X';
else
fmt[1] = 'x';
leader[1] = fmt[1]; // 0x or 0X (or \0X)
}
else
fmt[1] = 'o';
if (x_flags & showbase)
leader[0] = '0';
}
else if ((n>0) && (x_flags & showpos))
{
leader[0] = '+';
}
}
sprintf(obuffer,fmt,n);
writepad(leader,obuffer);
osfx();
}
return *this;
}