Standard library header <stdio.h>
This header is part of input/output library, providing generic file operation support and supplies I/O functions that work with narrow characters.
Types
| object type, capable of holding all information needed to control a C I/O stream (typedef) |
|
| non-array complete object type, capable of uniquely specifying a position and multibyte parser state in a file (typedef) |
Predefined standard streams
| expression of type FILE* associated with the input stream expression of type FILE* associated with the output stream expression of type FILE* associated with the error output stream (macro constant) |
Functions
File access |
|
|
(C11) | opens a file (function) |
|
(C11) | open an existing stream with a different name (function) |
| closes a file (function) |
|
| synchronizes an output stream with the actual file (function) |
|
| sets the buffer for a file stream (function) |
|
| sets the buffer and its size for a file stream (function) |
|
Direct input/output |
|
| reads from a file (function) |
|
| writes to a file (function) |
|
Unformatted input/output |
|
Narrow character |
|
| gets a character from a file stream (function) |
|
| gets a character string from a file stream (function) |
|
| writes a character to a file stream (function) |
|
| writes a character string to a file stream (function) |
|
reads a character from stdin (function) |
|
|
(removed in C11)(C11) | reads a character string from stdin (function) |
writes a character to stdout (function) |
|
writes a character string to stdout (function) |
|
| puts a character back into a file stream (function) |
|
Formatted input/output |
|
Narrow character |
|
|
(C11)(C11)(C11) | reads formatted input from stdin, a file stream or a buffer (function) |
|
(C99)(C99)(C99)(C11)(C11)(C11) | reads formatted input from stdin, a file stream or a bufferusing variable argument list (function) |
|
(C99)(C11)(C11)(C11)(C11) | prints formatted output to stdout, a file stream or a buffer (function) |
|
(C99)(C11)(C11)(C11)(C11) | prints formatted output to stdout, a file stream or a bufferusing variable argument list (function) |
File positioning |
|
| returns the current file position indicator (function) |
|
| gets the file position indicator (function) |
|
| moves the file position indicator to a specific location in a file (function) |
|
| moves the file position indicator to a specific location in a file (function) |
|
| moves the file position indicator to the beginning in a file (function) |
|
Error handling |
|
| clears errors (function) |
|
| checks for the end-of-file (function) |
|
| checks for a file error (function) |
|
displays a character string corresponding of the current error to stderr (function) |
|
Operations on files |
|
| erases a file (function) |
|
| renames a file (function) |
|
|
(C11) | returns a pointer to a temporary file (function) |
|
(C11) | returns a unique filename (function) |
Macro constants
|
EOF | integer constant expression of type int and negative value (macro constant) |
|
FOPEN_MAX | maximum number of files that can be open simultaneously (macro constant) |
|
FILENAME_MAX | size needed for an array of char to hold the longest supported file name (macro constant) |
|
_PRINTF_NAN_LEN_MAX
(C23) | the maximum number of characters output for any (possibly negated) NaN value (macro constant) |
|
BUFSIZ | size of the buffer used by setbuf (macro constant) |
|
_IOFBF_IOLBF_IONBF | indicates the buffering mode (fully buffered / line buffered / unbuffered) to be set by setvbuf (macro constant) |
|
SEEK_SETSEEK_CURSEEK_END | indicates the offset origin (beginning / current position / end) to be used by fseek (macro constant) |
|
TMP_MAXTMP_MAX_S
(C11) | maximum number of unique filenames that can be generated by tmpnam / tmpnam_s (macro constant) |
|
L_tmpnamL_tmpnam_s
(C11) | size needed for an array of char to hold the result of tmpnam / tmpnam_s (macro constant) |
Synopsis
#define __STDC_VERSION_STDIO_H__ 202311L typedef /* see description */ FILE; typedef /* see description */ size_t; typedef /* see description */ FILE; typedef /* see description */ fpos_t; #define NULL /* see description */ #define _IOFBF /* see description */ #define _IOLBF /* see description */ #define _IONBF /* see description */ #define BUFSIZ /* see description */ #define EOF /* see description */ #define FOPEN_MAX /* see description */ #define FILENAME_MAX /* see description */ #define L_tmpnam /* see description */ #define SEEK_CUR /* see description */ #define SEEK_END /* see description */ #define SEEK_SET /* see description */ #define TMP_MAX /* see description */ #define stdin /* see description */ #define stdout /* see description */ #define stderr /* see description */ #define _PRINTF_NAN_LEN_MAX /* see description */ int remove(const char* filename); int rename(const char* old, const char* new); FILE* tmpfile(void); char* tmpnam(char* s); int fclose(FILE* stream); int fflush(FILE* stream); FILE* fopen(const char* restrict filename, const char* restrict mode); FILE* freopen(const char* restrict filename, const char* restrict mode, FILE* restrict stream); void setbuf(FILE* restrict stream, char* restrict buf); int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size); int printf(const char* restrict format, ...); int scanf(const char* restrict format, ...); int snprintf(char* restrict s, size_t n, const char* restrict format, ...); int sprintf(char* restrict s, const char* restrict format, ...); int sscanf(const char* restrict s, const char* restrict format, ...); int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg); int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); int vprintf(const char* restrict format, va_list arg); int vscanf(const char* restrict format, va_list arg); int vsnprintf(char* restrict s, size_t n, const char* restrict format, va_list arg); int vsprintf(char* restrict s, const char* restrict format, va_list arg); int vsscanf(const char* restrict s, const char* restrict format, va_list arg); int fgetc(FILE* stream); char* fgets(char* restrict s, int n, FILE* restrict stream); int fputc(int c, FILE* stream); int fputs(const char* restrict s, FILE* restrict stream); int getc(FILE* stream); int getchar(void); 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* restrict ptr, size_t size, size_t nmemb, FILE* restrict stream); size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, FILE* restrict stream); int fgetpos(FILE* restrict stream, fpos_t* restrict 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); int fprintf(FILE* restrict stream, const char* restrict format, ...); int fscanf(FILE* restrict stream, const char* restrict format, ...);
Only if the implementation defines __STDC_LIB_EXT1__ and additionally the user code defines __STDC_WANT_LIB_EXT1__ before any inclusion of <stdio.h>:
#if defined(__STDC_WANT_LIB_EXT1__) #define L_tmpnam_s /* see description */ #define TMP_MAX_S /* see description */ typedef /* see description */ errno_t; typedef /* see description */ rsize_t; errno_t tmpfile_s(FILE* restrict* restrict streamptr); errno_t tmpnam_s(char* s, rsize_t maxsize); errno_t fopen_s(FILE* restrict* restrict streamptr, const char* restrict filename, const char* restrict mode); errno_t freopen_s(FILE* restrict* restrict newstreamptr, const char* restrict filename, const char* restrict mode, FILE* restrict stream); int fprintf_s(FILE* restrict stream, const char* restrict format, ...); int fscanf_s(FILE* restrict stream, const char* restrict format, ...); int printf_s(const char* restrict format, ...); int scanf_s(const char* restrict format, ...); int snprintf_s(char* restrict s, rsize_t n, const char* restrict format, ...); int sprintf_s(char* restrict s, rsize_t n, const char* restrict format, ...); int sscanf_s(const char* restrict s, const char* restrict format, ...); int vfprintf_s(FILE* restrict stream, const char* restrict format, va_list arg); int vfscanf_s(FILE* restrict stream, const char* restrict format, va_list arg); int vprintf_s(const char* restrict format, va_list arg); int vscanf_s(const char* restrict format, va_list arg); int vsnprintf_s(char* restrict s, rsize_t n, const char* restrict format, va_list arg); int vsprintf_s(char* restrict s, rsize_t n, const char* restrict format, va_list arg); int vsscanf_s(const char* restrict s, const char* restrict format, va_list arg); char* gets_s(char* s, rsize_t n); #endif
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/c/header/stdio