Overview of functions
Most of the C file input/output functions are defined in stdio.h (cstdio header in C++).
Byte
character
Wide
character
Description
fopen
opens a file
freopen
opens a different file with an existing stream
fflush
synchronizes an output stream with the actual file
fclose
closes a file
setbuf
sets the buffer for a file stream
setvbuf
sets the buffer and its size for a file stream
File access
fwide
switches a file stream between wide character I/O and narrow character
I/O
fread
reads from a file
Direct
input/output
fwrite
writes to a file
fgetc
getc
fgetwc
getwc
reads a byte/wchar_t from a file stream
fgets
fgetws
reads a byte/wchar_t string from a file stream
fputc
putc
fputwc
putwc
writes a byte/wchar_t to a file stream
fputs
fputws
writes a byte/wchar_t string to a file stream
getchar
getwchar
reads a byte/wchar_t from stdin
gets
N/A
reads a byte string from stdin
putchar
putwchar
writes a byte/wchar_t to stdout
puts
N/A
writes a byte string to stdout
Unformatted
input/output
ungetc
ungetwc
puts a byte/wchar_t back into a file stream
scanf
fscanf
sscanf
wscanf
fwscanf
swscanf
reads formatted byte/wchar_t input from stdin,
a file stream or a buffer
vscanf
vfscanf
vsscanf
vwscanf
vfwscanf
vswscanf
reads formatted input byte/wchar_t from stdin,
a file stream or a buffer using variable argument list
printf
fprintf
sprintf
snprintf
wprintf
fwprintf
swprintf
prints formatted byte/wchar_t output to stdout,
a file stream or a buffer
Formatted
input/output
vprintf
vfprintf
vsprintf
vsnprintf
vwprintf
vfwprintf
vswprintf
prints formatted byte/wchar_t output to stdout,
a file stream, or a buffer using variable argument list
ftell
returns the current file position indicator
fgetpos
gets the file position indicator
fseek
moves the file position indicator to a specific location in a file
fsetpos
moves the file position indicator to a specific location in a file
File positioning
rewind
moves the file position indicator to the beginning in a file
clearerr
clears errors
feof
checks for the end-of-file
ferror
checks for a file error
Error
handling
perror
displays a character string corresponding of the current error to stderr