ostrptr.cpp

来自「C标准库源代码」· C++ 代码 · 共 35 行

CPP
35
字号
/***
* ostrptr.cpp - definitions for ostream operator<<(const void*) member function
*
*       Copyright (c) 1991-1997, Microsoft Corporation.  All rights reserved.
*
*Purpose:
*       Member function definition for ostream operator<<(const void*).
*
*******************************************************************************/

#include <cruntime.h>
#include <internal.h>
#include <stdio.h>
#include <iostream.h>
#pragma hdrstop

ostream& ostream::operator<<(const void * ptr)
{
_WINSTATIC char obuffer[12];
_WINSTATIC char fmt[4] = "%p";
_WINSTATIC char leader[4] = "0x";
    if (opfx())
        {
        if (ptr)
            {
            if (x_flags & uppercase)
                leader[1] = 'X';
            }
        sprintf(obuffer,fmt,ptr);
        writepad(leader,obuffer);
        osfx();
        }
    return *this;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?