cout internal
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的更多相关文章
- c++ --> cin和cout输入输出格式
cin和cout输入输出格式 Cout 输出 1>. bool型输出 cout << true <<" or " << false < ...
- C++ cout格式化输出(转)
C++ cout格式化输出(转) 这篇文章主要讲解如何在C++中使用cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/pr ...
- C++的cout高阶格式化操作
这篇文章主要讲解如何在C++中使用cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/printf,仅使用cout来完成一切 ...
- C++ Primer Plus读书笔记
第五章 循环和关系表达式 1. 2.类别别名: (1) #define FLOAT_POINTER float * FLOAT_POINTER pa, pb; 预处理器置换将该声明转换成 flo ...
- C++的那些事:流与IO类
1.流的概念 "流"就是"流动",是物质从一处向另一处流动的过程,比如我们能感知到的水流.C++的流是指信息从外部输入设备(如键盘和磁盘)向计算机内部(即内存) ...
- 29.C++- 异常处理
C++内置了异常处理的语法元素 try catch try语句处理正常代码逻辑 当try语句发现异常时,则通过throw语句抛出异常,并退出try语句 catch语句处理异常情况 当throw语句抛出 ...
- C++ Primer Plus (Stephen Prata 著)
第1章 预备知识 (已看) 第2章 开始学习C++ (已看) 第3章 处理数据 (已看) 第4章 复合类型 (已看) 第5章 循环和关系表达式 (已看) 第6章 分支语句和逻辑运算符 (已看) 第7章 ...
- C++知识整理(在此感谢大牛的整理)
这篇文章主要讲解如何在C++中使用cin/cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/printf,仅使用cin/c ...
- 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 ...
随机推荐
- jQuery学习教程(2)
由于一件事情打断了我的生活节奏,每天都学习都在托托拉拉,导致很多进度都没有达到自己预期的效果 在上一个章节我学到了环境的搭建,以及对jquery的熟悉.现在开始对其具体进行熟悉了. 一.如何使用选择器 ...
- Ajax 异步 XMLHttpRequest
1.GET方式 1.1设置参数 xhr.open("GET", "GetAreasByAjax.ashx?isAjax=1 ...
- jQuery iframe 自适应高宽度
Html <iframe id="你的id" src="你要嵌入的页面" scrolling="no" frameborder=&qu ...
- 不能正确获得上次构建以来的Commit
不能正确获得上次构建以来的Commit 如何解决?
- svn-添加忽略文件
svn ps svn:ignore '文件夹名|文件名(不能是文件夹/文件名)' . svn pe svn:ignore . export SVN_EDITOR=/usr/bin/vim #设置环境变 ...
- phpstorm配置Xdebug进行调试PHP教程
运行环境: PHPSTORM版本 : 8.0.1 PHP版本 : 5.6.2 xdebug版本:php_xdebug-2.2.5-5.6-vc11-x86_64.dll ps : php版本和xdeb ...
- Python Tips and Traps(一)
1.如果想得到一个列表的index和内容,可以通过enumerate快速实现 drinks = ['coffee','tea', 'milk', 'water'] for index, drink i ...
- C语言-06复杂数据类型-03指针
指针变量的定义 变量类型 *变量名; #include <stdio.h> int main() { // 指针就一个作用:能够根据一个地址值,访问对应的存储空间 // 指针变量p前面的i ...
- Word添加新编号
要用到(1)(2),不想手写,但是word只有1.2.3和1)2)3),我就自定义哦.
- BZOJ 1828: [Usaco2010 Mar]balloc 农场分配
Description Input 第1行:两个用空格隔开的整数:N和M * 第2行到N+1行:第i+1行表示一个整数C_i * 第N+2到N+M+1行: 第i+N+1行表示2个整数 A_i和B_i ...