标准库标头 <cstdio>

来自cppreference.com
< cpp‎ | header
 
 
标准库标头
注:修订记号中的反斜杠 '/' 意味着此标头被弃用和/或被移除。
语言支持
概念
<concepts> (C++20)
诊断
<system_error> (C++11)
内存管理
<memory_resource> (C++17)  
元编程
<type_traits> (C++11)
<ratio> (C++11)
通用工具
<utility>
<tuple> (C++11)
<optional> (C++17)
<variant> (C++17)
<any> (C++17)
<expected> (C++23)
<bitset>

<charconv> (C++17)
<format> (C++20)
<bit> (C++20)

字符串
<cuchar> (C++11)

容器
<flat_set> (C++23)
<span> (C++20)
<mdspan> (C++23)

迭代器
<iterator>
范围
<ranges> (C++20)
<generator> (C++23)
算法
数值
<cfenv> (C++11)
<complex>
<numbers> (C++20)

日期时间
<chrono> (C++11)
本地化
<codecvt> (C++11/17)
输入/输出
<filesystem> (C++17)
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98/)
正则表达式
<regex>
并发支持
<stop_token> (C++20)
<thread> (C++11)
<atomic> (C++11)
<stdatomic.h> (C++23)
<mutex> (C++11)
<shared_mutex> (C++14)
<condition_variable> (C++11)  
<semaphore> (C++20)
<latch> (C++20)
<barrier> (C++20)
<future> (C++11)

C 兼容
<cstdbool> (C++11/17/20)  
<ccomplex> (C++11/17/20)
<ctgmath> (C++11/17/20)

<cstdalign> (C++11/17/20)

<ciso646> (C++20 前)

 

此标头原作为 <stdio.h> 存在于 C 标准库。

此头文件是 C 风格输入/输出库的一部分。

目录

类型

对象类型,足以保有控制 C 输入/输出流所需的全部信息
(typedef) [编辑]
完整非数组对象类型,足以唯一指定文件中的位置,包含其多字节剖析状态
(typedef) [编辑]
sizeof 运算符返回的无符号整数类型
(typedef) [编辑]

实现定义的空指针常量
(宏常量) [编辑]
与输入流关联到 FILE* 类型表达式
与输出流关联的 FILE* 类型表达式
与错误输出流关联的 FILE* 类型表达式
(宏常量) [编辑]
EOF
拥有 int 类型和负值的整数常量表达式
(宏常量)
FOPEN_MAX
能同时打开的文件数
(宏常量)
FILENAME_MAX
要保有最长受支持文件名的 char 数组所需的长度
(宏常量)
BUFSIZ
std::setbuf 所用的缓冲区大小
(宏常量)
_IOFBF_IOLBF_IONBF
std::setbuf 的参数,指示全缓冲 I/O
std::setbuf 的参数,指示行缓冲 I/O
std::setbuf 的参数,指示无缓冲 I/O
(宏常量)
SEEK_SETSEEK_CURSEEK_END
std::fseek 的参数,指示从文件起始寻位
std::fseek 的参数,指示从当前文件位置寻位
std::fseek 的参数,指示从文件尾寻位
(宏常量)
TMP_MAX
std::tmpnam 所能生成的唯一文件名的最大数量
(宏常量)
L_tmpnam
保有 std::tmpnam 结果的 char 数组所需的大小
(宏常量)

函数

文件访问
打开文件
(函数) [编辑]
以不同名称打开既存流
(函数) [编辑]
关闭文件
(函数) [编辑]
将输出流与实际文件同步
(函数) [编辑]
为文件流设置缓冲区
(函数) [编辑]
为文件流设置缓冲区与其大小
(函数) [编辑]
直接输入/输出
从文件读取
(函数) [编辑]
写入文件
(函数) [编辑]
无格式输入/输出
窄字符
从文件流获取字符
(函数) [编辑]
从文件流获取字符串
(函数) [编辑]
写字符到文件流
(函数) [编辑]
写字符串到文件流
(函数) [编辑]
stdin 读取字符
(函数) [编辑]
(C++11 中弃用)(C++14 中移除)
stdin 读取字符串
(函数) [编辑]
写字符到 stdout
(函数) [编辑]
写字符串到 stdout
(函数) [编辑]
把字符放回文件流
(函数) [编辑]
有格式输入/输出
窄/多字节字符
stdin、文件流或缓冲区读取有格式输入
(函数) [编辑]
(C++11)(C++11)(C++11)
使用可变实参列表
stdin、文件流或缓冲区读取有格式输入
(函数) [编辑]
打印有格式输出到 stdout、文件流或缓冲区
(函数) [编辑]
使用可变实参列表
打印有格式输出到 stdout、文件流或缓冲区
(函数) [编辑]
文件寻位
返回当前文件位置指示器
(函数) [编辑]
获取文件位置指示器
(函数) [编辑]
移动文件位置指示器到文件中的指定位置
(函数) [编辑]
移动文件位置指示器到文件中的指定位置
(函数) [编辑]
移动文件位置指示器到文件起始
(函数) [编辑]
错误处理
清除错误
(函数) [编辑]
检查文件尾
(函数) [编辑]
检查文件错误
(函数) [编辑]
显示对应当前错误的字符串于 stderr
(函数) [编辑]
文件上的操作
删除文件
(函数) [编辑]
重命名文件
(函数) [编辑]
创建并打开一个临时、自动移除的文件
(函数) [编辑]
返回一个唯一独有的文件名
(函数) [编辑]

[编辑] 概要

namespace std {
  using size_t = /* 见描述 */;
  using FILE = /* 见描述 */;
  using fpos_t = /* 见描述 */;
}
 
#define NULL /* 见描述 */
#define _IOFBF /* 见描述 */
#define _IOLBF /* 见描述 */
#define _IONBF /* 见描述 */
#define BUFSIZ /* 见描述 */
#define EOF /* 见描述 */
#define FOPEN_MAX /* 见描述 */
#define FILENAME_MAX /* 见描述 */
#define L_tmpnam /* 见描述 */
#define SEEK_CUR /* 见描述 */
#define SEEK_END /* 见描述 */
#define SEEK_SET /* 见描述 */
#define TMP_MAX /* 见描述 */
#define stderr /* 见描述 */
#define stdin /* 见描述 */
#define stdout /* 见描述 */
 
namespace std {
  int remove(const char* filename);
  int rename(const char* old_p, const char* new_p);
  FILE* tmpfile();
  char* tmpnam(char* s);
  int fclose(FILE* stream);
  int fflush(FILE* stream);
  FILE* fopen(const char* filename, const char* mode);
  FILE* freopen(const char* filename, const char* mode, FILE* stream);
  void setbuf(FILE* stream, char* buf);
  int setvbuf(FILE* stream, char* buf, int mode, size_t size);
  int fprintf(FILE* stream, const char* format, ...);
  int fscanf(FILE* stream, const char* format, ...);
  int printf(const char* format, ...);
  int scanf(const char* format, ...);
  int snprintf(char* s, size_t n, const char* format, ...);
  int sprintf(char* s, const char* format, ...);
  int sscanf(const char* s, const char* format, ...);
  int vfprintf(FILE* stream, const char* format, va_list arg);
  int vfscanf(FILE* stream, const char* format, va_list arg);
  int vprintf(const char* format, va_list arg);
  int vscanf(const char* format, va_list arg);
  int vsnprintf(char* s, size_t n, const char* format, va_list arg);
  int vsprintf(char* s, const char* format, va_list arg);
  int vsscanf(const char* s, const char* format, va_list arg);
  int fgetc(FILE* stream);
  char* fgets(char* s, int n, FILE* stream);
  int fputc(int c, FILE* stream);
  int fputs(const char* s, FILE* stream);
  int getc(FILE* stream);
  int getchar();
  int putc(int c, FILE* stream);
  int putchar(int c);
  int puts(const char* s);
  int ungetc(int c, FILE* stream);
  size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
  size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream);
  int fgetpos(FILE* stream, fpos_t* pos);
  int fseek(FILE* stream, long int offset, int whence);
  int fsetpos(FILE* stream, const fpos_t* pos);
  long int ftell(FILE* stream);
  void rewind(FILE* stream);
  void clearerr(FILE* stream);
  int feof(FILE* stream);
  int ferror(FILE* stream);
  void perror(const char* s);
}

[编辑] 注解