Files
2025-10-25 03:02:53 +03:00

89 lines
9.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[c.files]
# 31 Input/output library [[input.output]](./#input.output)
## 31.13 C library files [c.files]
### [31.13.1](#cstdio.syn) Header <cstdio> synopsis [[cstdio.syn]](cstdio.syn)
[🔗](#header:%3ccstdio%3e)
#define __STDC_VERSION_STDIO_H__ 202311Lnamespace std {using size_t = *see [[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets")*; using FILE = *see below*; using fpos_t = *see below*;}#define NULL *see [[support.types.nullptr]](support.types.nullptr "17.2.3Null pointers")*#define _IOFBF *see below*#define _IOLBF *see below*#define _IONBF *see below*#define BUFSIZ *see below*#define EOF *see below*#define FOPEN_MAX *see below*#define FILENAME_MAX *see below*#define _PRINTF_NAN_LEN_MAX *see below*#define L_tmpnam *see below*#define SEEK_CUR *see below*#define SEEK_END *see below*#define SEEK_SET *see below*#define TMP_MAX *see below*#define stderr *see below*#define stdin *see below*#define stdout *see below*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);}
[1](#cstdio.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18970)
The contents and meaning of the header [<cstdio>](#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]") are the same as the C standard library header [<stdio.h>](support.c.headers.general#header:%3cstdio.h%3e "17.15.1General[support.c.headers.general]")[.](#cstdio.syn-1.sentence-1)
[2](#cstdio.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18974)
The return from each function call
that delivers data
to the host environment
to be written to a file (See also: ISO/IEC 9899:2024, 7.21.3)
is an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2Abstract machine"))[.](#cstdio.syn-2.sentence-1)
[3](#cstdio.syn-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18981)
Calls to the function tmpnam with an argument that is a null pointer value may
introduce a data race ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance")) with other calls to tmpnam with
an argument that is a null pointer value[.](#cstdio.syn-3.sentence-1)
See also: ISO/IEC 9899:2024, 7.23
### [31.13.2](#cinttypes.syn) Header <cinttypes> synopsis [[cinttypes.syn]](cinttypes.syn)
[🔗](#header:%3ccinttypes%3e)
#include <cstdint> // see [[cstdint.syn]](cstdint.syn "17.4.1Header <cstdint> synopsis")namespace std {using imaxdiv_t = *see below*; constexpr intmax_t imaxabs(intmax_t j); constexpr imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
intmax_t strtoimax(const char* nptr, char** endptr, int base);
uintmax_t strtoumax(const char* nptr, char** endptr, int base);
intmax_t wcstoimax(const wchar_t* nptr, wchar_t** endptr, int base);
uintmax_t wcstoumax(const wchar_t* nptr, wchar_t** endptr, int base); constexpr intmax_t abs(intmax_t); // optional, see belowconstexpr imaxdiv_t div(intmax_t, intmax_t); // optional, see below}#define __STDC_VERSION_INTTYPES_H__ 202311L#define PRId*N* *see below*#define PRIi*N* *see below*#define PRIo*N* *see below*#define PRIu*N* *see below*#define PRIx*N* *see below*#define PRIX*N* *see below*#define PRIb*N* *see below*#define PRIB*N* *see below*#define SCNd*N* *see below*#define SCNi*N* *see below*#define SCNo*N* *see below*#define SCNu*N* *see below*#define SCNx*N* *see below*#define SCNb*N* *see below*#define PRIdLEAST*N* *see below*#define PRIiLEAST*N* *see below*#define PRIoLEAST*N* *see below*#define PRIuLEAST*N* *see below*#define PRIxLEAST*N* *see below*#define PRIXLEAST*N* *see below*#define PRIbLEAST*N* *see below*#define PRIBLEAST*N* *see below*#define SCNdLEAST*N* *see below*#define SCNiLEAST*N* *see below*#define SCNoLEAST*N* *see below*#define SCNuLEAST*N* *see below*#define SCNxLEAST*N* *see below*#define SCNbLEAST*N* *see below*#define PRIdFAST*N* *see below*#define PRIiFAST*N* *see below*#define PRIoFAST*N* *see below*#define PRIuFAST*N* *see below*#define PRIxFAST*N* *see below*#define PRIXFAST*N* *see below*#define PRIbFAST*N* *see below*#define PRIBFAST*N* *see below*#define SCNdFAST*N* *see below*#define SCNiFAST*N* *see below*#define SCNoFAST*N* *see below*#define SCNuFAST*N* *see below*#define SCNxFAST*N* *see below*#define SCNbFAST*N* *see below*#define PRIdMAX *see below*#define PRIiMAX *see below*#define PRIoMAX *see below*#define PRIuMAX *see below*#define PRIxMAX *see below*#define PRIXMAX *see below*#define PRIbMAX *see below*#define PRIBMAX *see below*#define SCNdMAX *see below*#define SCNiMAX *see below*#define SCNoMAX *see below*#define SCNuMAX *see below*#define SCNxMAX *see below*#define SCNbMAX *see below*#define PRIdPTR *see below*#define PRIiPTR *see below*#define PRIoPTR *see below*#define PRIuPTR *see below*#define PRIxPTR *see below*#define PRIXPTR *see below*#define PRIbPTR *see below*#define PRIBPTR *see below*#define SCNdPTR *see below*#define SCNiPTR *see below*#define SCNoPTR *see below*#define SCNuPTR *see below*#define SCNxPTR *see below*#define SCNbPTR *see below*
[1](#cinttypes.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L19133)
The contents and meaning of the header [<cinttypes>](#header:%3ccinttypes%3e "31.13.2Header <cinttypes> synopsis[cinttypes.syn]") are the same as the C standard library header [<inttypes.h>](support.c.headers.general#header:%3cinttypes.h%3e "17.15.1General[support.c.headers.general]"),
with the following changes:
- [(1.1)](#cinttypes.syn-1.1)
The header [<cinttypes>](#header:%3ccinttypes%3e "31.13.2Header <cinttypes> synopsis[cinttypes.syn]") includes the header [<cstdint>](cstdint.syn#header:%3ccstdint%3e "17.4.1Header <cstdint> synopsis[cstdint.syn]") instead
of [<stdint.h>](support.c.headers.general#header:%3cstdint.h%3e "17.15.1General[support.c.headers.general]"), and
- [(1.2)](#cinttypes.syn-1.2)
if and only if the type intmax_t designates an extended integer
type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types")), the following function signatures are added:constexpr intmax_t abs(intmax_t);constexpr imaxdiv_t div(intmax_t, intmax_t); which shall have the same semantics as the function signaturesconstexpr intmax_t imaxabs(intmax_t) andconstexpr imaxdiv_t imaxdiv(intmax_t, intmax_t), respectively[.](#cinttypes.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.8
[2](#cinttypes.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L19155)
Each of the PRI macros listed in this subclause
is defined if and only if the implementation
defines the corresponding [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") in [[cstdint.syn]](cstdint.syn "17.4.1Header <cstdint> synopsis")[.](#cinttypes.syn-2.sentence-1)
Each of the SCN macros listed in this subclause
is defined if and only if the implementation
defines the corresponding [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") in [[cstdint.syn]](cstdint.syn "17.4.1Header <cstdint> synopsis") and
has a suitable fscanf length modifier for the type[.](#cinttypes.syn-2.sentence-2)
Each of the PRIB macros listed in this subclause
is defined if and only if fprintf supports
the B conversion specifier[.](#cinttypes.syn-2.sentence-3)