C-style file input/output

From Cppreference

< cpp | io
Jump to: navigation, search

The <cstdio> header provides generic file operation support and supplies functions with narrow character input/output capabilities.

The <cwchar> header supplies functions with wide character input/output capabilities.

Contents

[edit] Functions

File access
fopen
opens a file
(function)
freopen
open an existing stream with a different name
(function)
fflush
synchronizes an output stream with the actual file
(function)
fclose
closes a file
(function)
setbuf
sets the buffer for a file stream
(function)
setvbuf
sets the buffer and its size for a file stream
(function)
fwide
switches a file stream between wide character I/O and narrow character I/O
(function)
Direct input/output
fread
reads from a file
(function)
fwrite
writes to a file
(function)
Unformatted input/output
Narrow character
fgetc
getc
gets a character from a file stream
(function)
fgets
gets a character string from a file stream
(function)
fputc
putc
writes a character to a file stream
(function)
fputs
writes a character string to a file stream
(function)
getchar
reads a character from stdin
(function)
gets
reads a character string from stdin
(function)
putchar
writes a character to stdout
(function)
puts
writes a character string to stdout
(function)
ungetc
puts a character back into a file stream
(function)
Wide character
fgetwc
getwc
gets a wide character from a file stream
(function)
fgetws
gets a wide character string from a file stream
(function)
fputwc
putwc
writes a wide character to a file stream
(function)
fputws
writes a wide character string to a file stream
(function)
getwchar
reads a wide character from stdin
(function)
putwchar
writes a wide character to stdout
(function)
ungetwc
puts a wide character back into a file stream
(function)
Formatted input/output
Narrow character
scanf
fscanf
sscanf
reads formatted input from stdin, a file stream or a buffer
(function)
vscanf
vfscanf
vsscanf
(C++11)
(C++11)
(C++11)
reads formatted input from stdin, a file stream or a buffer
using variable argument list
(function)
printf
fprintf
sprintf
snprintf



(C++11)
prints formatted output to stdout, a file stream or a buffer
(function)
vprintf
vfprintf
vsprintf
vsnprintf



(C++11)
prints formatted output to stdout, a file stream or a buffer
using variable argument list
(function)
Wide character
wscanf
fwscanf
swscanf
reads formatted wide character input from stdin, a file stream or a buffer
(function)
vwscanf
vfwscanf
vswscanf
(C++11)
(C++11)
(C++11)
reads formatted wide character input from stdin, a file stream
or a buffer using variable argument list
(function)
wprintf
fwprintf
swprintf
prints formatted wide character output to stdout, a file stream or a buffer
(function)
vwprintf
vfwprintf
vswprintf
prints formatted wide character output to stdout, a file stream
or a buffer using variable argument list
(function)
File positioning
ftell
returns the current file position indicator
(function)
fgetpos
gets the file position indicator
(function)
fseek
moves the file position indicator to a specific location in a file
(function)
fsetpos
moves the file position indicator to a specific location in a file
(function)
rewind
moves the file position indicator to the beginning in a file
(function)
Error handling
clearerr
clears errors
(function)
feof
checks for the end-of-file
(function)
ferror
checks for a file error
(function)
perror
displays a character string corresponding of the current error to stderr
(function)
Operations on files
remove
erases a file
(function)
rename
renames a file
(function)
tmpfile
returns a pointer to a temporary file
(function)
tmpnam
returns an unique filename
(function)

[edit] Macros