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 | |
|---|---|---|---|
| File access | 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 | ||
fwide |
switches a file stream between wide character I/O and narrow character I/O | ||
| Direct input/output |
fread |
reads from a file | |
fwrite |
writes to a file | ||
| Unformatted input/output |
fgetcgetc |
fgetwcgetwc |
reads a byte/wchar_t from a file stream |
fgets |
fgetws |
reads a byte/wchar_t line from a file stream |
|
fputcputc |
fputwcputwc |
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 |
reads a byte string from stdin (deprecated in C99, obsoleted in C11) | ||
putchar |
putwchar |
writes a byte/wchar_t to stdout |
|
puts |
writes a byte string to stdout | ||
ungetc |
ungetwc |
puts a byte/wchar_t back into a file stream |
|
| Formatted input/output |
scanffscanfsscanf |
wscanffwscanfswscanf |
reads formatted byte/wchar_t input from stdin,a file stream or a buffer |
vscanfvfscanfvsscanf |
vwscanfvfwscanfvswscanf |
reads formatted input byte/wchar_t from stdin,a file stream or a buffer using variable argument list |
|
printffprintfsprintfsnprintf |
wprintffwprintfswprintf |
prints formatted byte/wchar_t output to stdout,a file stream or a buffer |
|
vprintfvfprintfvsprintfvsnprintf |
vwprintfvfwprintfvswprintf |
prints formatted byte/wchar_t output to stdout,a file stream, or a buffer using variable argument list |
|
| File positioning | 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 | ||
rewind |
moves the file position indicator to the beginning in a file | ||
| Error handling |
clearerr |
clears errors | |
feof |
checks for the end-of-file | ||
ferror |
checks for a file error | ||
perror |
displays a character string corresponding of the current error to stderr | ||
| Operations on files |
remove |
erases a file | |
rename |
renames a file | ||
tmpfile |
returns a pointer to a temporary file | ||
tmpnam |
returns a unique filename | ||
Read more about this topic: C File Input/output
Famous quotes containing the word functions:
“If photography is allowed to stand in for art in some of its functions it will soon supplant or corrupt it completely thanks to the natural support it will find in the stupidity of the multitude. It must return to its real task, which is to be the servant of the sciences and the arts, but the very humble servant, like printing and shorthand which have neither created nor supplanted literature.”
—Charles Baudelaire (18211867)