cout internal

*/-->

pre {
background-color: #2f4f4f;line-height: 1.6;
FONT: 10.5pt Consola,"Bitstream Vera Sans", Courier New, helvetica;
color:wheat;
}
.h3 {
margin-left: 10pt;
}

cout internal

先看看cout是这么定义的:
istream cout(&fout)

//C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\cout.cpp

// cout -- initialize standard output stream
#include <fstream>
#include <iostream> #pragma warning(disable: 4074)
#pragma init_seg(compiler)
static std::_Init_locks initlocks; _STD_BEGIN
// OBJECT DECLARATIONS __PURE_APPDOMAIN_GLOBAL static filebuf fout(_cpp_stdout);
#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern ostream cout(&fout);
#else
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2 ostream cout(&fout);
#endif
// INITIALIZATION CODE
struct _Init_cout
{ // ensures that cout is initialized
__CLR_OR_THIS_CALL _Init_cout()
{ // initialize cout
_Ptr_cout = &cout;
if (_Ptr_cin != 0)
_Ptr_cin->tie(_Ptr_cout);
if (_Ptr_cerr != 0)
_Ptr_cerr->tie(_Ptr_cout);
if (_Ptr_clog != 0)
_Ptr_clog->tie(_Ptr_cout);
}
};
__PURE_APPDOMAIN_GLOBAL static _Init_cout init_cout; _STD_END /*
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.03:0009 */

再看看 _cpp_stdout 是怎么回事?

//C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\yvals.h

   #define _cpp_stdin  (&(__iob_func())[0])
#define _cpp_stdout (&(__iob_func())[1])
#define _cpp_stderr (&(__iob_func())[2])
#define _cpp_isleadbyte(c) (__pctype_func()[(unsigned char)(c)] & _LEADBYTE)

关于 __iob_func():
__iob_func() returns a pointer to the array of FILE descriptors that holds
stdin, stdout, stderr and any FILE objects opened through the C runtime
library. See the MSVC runtime library source _file.c.

//C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\_file.c

/*
* FILE descriptors; preset for stdin/out/err (note that the __tmpnum field
* is not initialized)
*/
FILE _iob[_IOB_ENTRIES] = {
/* _ptr, _cnt, _base, _flag, _file, _charbuf, _bufsiz */ /* stdin (_iob[0]) */ { _bufin, 0, _bufin, _IOREAD | _IOYOURBUF, 0, 0, _INTERNAL_BUFSIZ }, /* stdout (_iob[1]) */ { NULL, 0, NULL, _IOWRT, 1, 0, 0 }, /* stderr (_iob[3]) */ { NULL, 0, NULL, _IOWRT, 2, 0, 0 }, }; /*
* Initializer and terminator for stdio
*/
int __cdecl __initstdio(void);
void __cdecl __endstdio(void); _CRTALLOC(".CRT$XIC") static _PIFV pinit = __initstdio; _CRTALLOC(".CRT$XPXA") static _PVFV pterm = __endstdio;
//C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\internal.h

struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;

Post by: Jalen Wang (转载请注明出处)

cout internal的更多相关文章

  1. c++ --> cin和cout输入输出格式

    cin和cout输入输出格式 Cout 输出 1>. bool型输出 cout << true <<" or " << false < ...

  2. C++ cout格式化输出(转)

    C++ cout格式化输出(转) 这篇文章主要讲解如何在C++中使用cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/pr ...

  3. C++的cout高阶格式化操作

    这篇文章主要讲解如何在C++中使用cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/printf,仅使用cout来完成一切 ...

  4. C++ Primer Plus读书笔记

    第五章 循环和关系表达式 1. 2.类别别名: (1)   #define FLOAT_POINTER float * FLOAT_POINTER pa, pb; 预处理器置换将该声明转换成  flo ...

  5. C++的那些事:流与IO类

    1.流的概念 "流"就是"流动",是物质从一处向另一处流动的过程,比如我们能感知到的水流.C++的流是指信息从外部输入设备(如键盘和磁盘)向计算机内部(即内存) ...

  6. 29.C++- 异常处理

    C++内置了异常处理的语法元素 try catch try语句处理正常代码逻辑 当try语句发现异常时,则通过throw语句抛出异常,并退出try语句 catch语句处理异常情况 当throw语句抛出 ...

  7. C++ Primer Plus (Stephen Prata 著)

    第1章 预备知识 (已看) 第2章 开始学习C++ (已看) 第3章 处理数据 (已看) 第4章 复合类型 (已看) 第5章 循环和关系表达式 (已看) 第6章 分支语句和逻辑运算符 (已看) 第7章 ...

  8. C++知识整理(在此感谢大牛的整理)

    这篇文章主要讲解如何在C++中使用cin/cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/printf,仅使用cin/c ...

  9. Tree - Rooted Trees

    Rooted Trees A graph G = (V, E) is a data structure where V is a finite set of vertices and E is a b ...

随机推荐

  1. 设计模式之 Factory Method 工厂方法

    看到的比较有意思的一篇描述工厂方法的文章. http://www.codeproject.com/Articles/492900/From-No-Factory-to-Factory-Method 总 ...

  2. PHP生成制作验证码

    看完就会,不会你打我,话不多说.开搞(人狠话不多) 1.0 首先先看代码 <?php header("Content-Type:text/html;Charset=UTF-8" ...

  3. CentOS 6.4 使用第三方源

      1.EPEL源 CentOS 6.x 32-bit (x86/i386):rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/ep ...

  4. php中mysqli 处理查询结果集的几个方法

    最近对php查询mysql处理结果集的几个方法不太明白的地方查阅了资料,在此整理记下 Php使用mysqli_result类处理结果集有以下几种方法 fetch_all() 抓取所有的结果行并且以关联 ...

  5. NodeJS加MongoDB应用入门

    OS:Windows 7 1.下载安装MongoDB:http://www.mongodb.org/downloads 2.下载安装NodeJS:http://nodejs.org/ 3.运行Mong ...

  6. 第一个CUDA程序

    开始学CUDA 先写一个简单的 #include<iostream>__global__ void add( int a, int b, int *c ) { *c = a + b;}in ...

  7. Xcode:只修改 Bundle Identifier,不修改项目名

    找到 xx-Info.plist,打开 直接去修改 Bundle identifier 即可(默认后缀是项目名字).

  8. NGINX+UWSGI部署生产的DJANGO代码

    并且NGINX不用ROOT帐户哟. 1,编译安装NGINX及UWSGI及DJANGO,不表述 2,将NGINX文件夹更改为普通用户拥有.但执行文件NGINX仍为ROOT,运行如下命令加入特殊权限标志位 ...

  9. Android UI 设计准则

    Design Principles  设计准则 These design principles were developed by and for the Android User Experienc ...

  10. [cocos2d]场景切换以及切换进度显示

    本文主要分两个部分叙述,第一是场景切换,第二是场景切换的进度显示. 一.场景切换 参考learn-iphone-and-ipad-cocos2d-game-development 第五章内容 coco ...