C++ Reference: Standard C++ Library reference: C Library: cstdio

C++官网参考链接:https://cplusplus.com/reference/cstdio/

头文件 
<cstdio> (stdio.h)
C库执行输入/输出操作
输入和输出操作也可以在C++中使用C标准输入和输出库(cstdio,在C语言中称为stdio.h)来执行。这个库使用所谓的流来操作物理设备,如键盘、打印机、终端或系统支持的任何其他的文件类型。流是以统一的方式与这些交互的抽象;所有流都具有类似的属性,独立于它们所关联的物理媒体的单个特征。
流在cstdio库中作为指向FILE对象的指针进行处理。指向FILE对象的指针唯一地标识一个流,并在涉及该流的操作中用作形参。
还有三种标准流:stdinstdoutstderr,它们会自动创建并为使用标准库的所有程序打开。

流属性
流具有一些属性,这些属性定义了可以在它们上使用哪些函数,以及这些函数将如何处理通过它们输入或输出的数据。这些属性中的大多数都是在使用fopen函数将流与文件(打开)关联时定义的:
读/写访问
指定流是否具有对其关联的物理媒体的读或写访问权(或两者都有)。 
文本/二进制
文本流被认为代表一组文本行,每一行以一个换行字符结束。根据运行应用程序的环境,文本流可能会发生一些字符转换,以使某些特殊字符适应环境的文本文件规范。另一方面,二进制流是从物理媒体中写入或读取的字符序列,无需转换,与读取或写入流的字符具有一一对应关系。
缓冲
缓冲区是一个内存块,在对相关文件或设备进行物理读写之前,在这里积累数据。流可以是完全缓冲的,行缓冲的或无缓冲的。在完全缓冲的流上,数据在缓冲区被填满时被读/写,在行缓冲流上,这发生在遇到换行字符时,而在无缓冲流上,字符被尽可能快地读/写。
方向
在打开时,流没有方向。一旦对它们执行了输入/输出操作,它们就会变成面向字节或面向宽字符的,这取决于所执行的操作(通常,<cstdio>中定义的函数是面向字节的,而<cwchar>中定义的函数是面向宽字符的)。更多信息请参见cwchar

指示符 
流有特定的内部指示符,用于指定它们的当前状态,并影响对它们执行的某些输入和输出操作的行为:
错误指示符 
当与流相关的操作发生错误时设置此指示符。这个指示符可以用ferror函数检查,并且可以通过调用clearerrfreopenrewind来重置。 
文件结束指示符
设置此值时,表示对流执行的最后一次读写操作已到达文件结束。它可以用feof函数检查,并可以通过调用clearerrfreopen或调用任何重新定位函数(rewindfseekfsetpos)来重置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
C++ Standard Library Quick Reference by Peter Van Weert, Marc Gregoire 2016 | ISBN: 1484218752 | English | 206 pages PDF+EPUB This quick reference is a condensed reference guide to the essential data structures, algorithms, and functions provided by the C++ Standard Library. More specifically, this is a compact collection of essential classes and functions, used by C++ programmers on a daily basis. The C++ Standard Library Quick Reference features core classes for strings, I/O streams, and various generic containers, as well as a comprehensive set of algorithms to manipulate them. In recent years, the C++11 and C++14 standards have added even more efficient container classes, a new powerful regular expression library, and a portable multithreading library featuring threads, mutexes, condition variables, and atomic variables. Needless to say, it is hard to know and remember all the possibilities, details, and intricacies of this vast and growing library. This handy reference guide is therefore indispensable to any C++ programmer. It offers a condensed, well-structured summary of all essential aspects of the C++ Standard Library, including all aforementioned functionality. No page-long, repetitive examples or obscure, rarely used features. Instead, everything you need to know and watch out for in practice is outlined in a compact, to-the-point style, interspersed with well-chosen, clarifying examples. The book does not explain the C++ language or syntax, but is accessible to anyone with basic C++ knowledge. Even the most experienced C++ programmer though will learn a thing or two from it and find it a useful memory-aid. What You Will Learn • The essentials that the C++ Standard Library has to offer • How to use containers to efficiently store and retrieve your data • How to use algorithms to inspect and manipulate your data • How lambda expressions allow for elegant use of algorithms • What the standard string class provides and how to use it • What functionality the library provides for file and stream-based I/O • What smart pointers are and how to use them to prevent memory leaks • How to write safe and efficient multi-threaded code using the C++11 threading libraries

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_40186813

你的能量无可限量。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值