cout internal
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 (转载请注明出处)
转载于:https://www.cnblogs.com/jalenwang/p/3235982.html
cout internal相关推荐
- C++的cout高阶格式化操作
(敬告:当您的浏览器以非默认字体浏览本文时,段落格式可能会出现偏差) 这篇文章主要讲解如何在C++中使用cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过 ...
- 【ACM】树 小结
树是一种表达层级结构的数据结构,也是实现高效算法与数据结构的基础. 学习之前的基础:数组,循环处理,结构体,递归函数. 树:由结点(node)和连接结点的边(edge)构成. ...
- C++ Primer 5th笔记(chap 17 标准库特殊设施)输出补白
1. 控制数据格式 定义在iomapip中的操作符 操作符 描述 setfill(ch) 用ch填充空白 setprecision(ch) 将浮点精度设置为n setw(ch) 读或写值的宽度为w个字 ...
- C++库文件导出可见性
导出符号 C++中除了语言级别的访问特性(公有.私有和保护)外,还有两个相关的概念允许暴露API中的符号,它们位于物理层次,分别是: 外部链接 导出可见性 外部链接 外部链接这个术语是指一个编译单元中 ...
- C++知识整理(在此感谢大牛的整理)
这篇文章主要讲解如何在C++中使用cin/cout进行高级的格式化输出操作,包括数字的各种计数法(精度)输出,左或右对齐,大小写等等.通过本文,您可以完全脱离scanf/printf,仅使用cin/c ...
- 29.C++- 异常处理
C++内置了异常处理的语法元素 try catch try语句处理正常代码逻辑 当try语句发现异常时,则通过throw语句抛出异常,并退出try语句 catch语句处理异常情况 当throw语句抛出 ...
- 【有根树】Rooted Trees C++
题目来源:Aizu - ALDS1_7_A 题目: A graph G = (V, E) is a data structure where V is a finite set of vertices ...
- C++ Primer Plus读书笔记
第五章 循环和关系表达式 1. 2.类别别名: (1) #define FLOAT_POINTER float * FLOAT_POINTER pa, pb; 预处理器置换将该声明转换成 flo ...
- 容易被误解的inline
C++中的inline是个容易被误解的关键字,即使是专家也常会犯错. 不信?请打开<Thinking in C++ 2rd Edition Volumn 1>,找到Chapter 9 ...
最新文章
- 【原创】TimeSten安装与配置
- 10万,买一辆自驾无忧的智能汽车
- tableau可视化数据分析60讲(二十二)-tableau常见面试题目
- 6.1添加首页和登录页静态模版
- 如何理解subplot绘制不规则子图的参数设置
- 有服务器风扇声音对胎儿有影响吗,大噪音对胎儿的影响
- linux之网络编程ICMP校验算法
- 矩池云课程版使用教程
- [E]PSM算法简析
- 为什么 Nginx 比 Apache 更牛叉?
- java计算机毕业设计实验室耗材管理系统源码+系统+数据库+lw文档+mybatis+运行部署
- 读懂K线,就能理解期货股票交易中人性的期望、猜疑、幻想、贪婪、恐惧...
- web前端开发基础班课程大纲
- 汉明码生成过程图文详解
- python中英文翻译
- “日志事件详细信息”(Log Event Details) 页面
- [转]用Mcafee打造自己的安全系统
- VB多层防火墙技术的研究-状态检测
- YOLO与voc格式互转,超详细
- 经纬财富:鄂尔多斯套单形成的表现与解套技巧