This chapter comprises functions to manage files or other input/output streams. Among these functions are subroutines to generate or scan strings according to specifications from a format string.
The underlying facilities for input and output depend on the host system, but these functions provide a uniform interface.
The corresponding declarations are in stdio.h.
The reentrant versions of these functions use macros
_stdin_r(reent) _stdout_r(reent) _stderr_r(reent)
instead of the globals stdin
, stdout
, and
stderr
. The argument reent is a pointer to a reentrancy
structure.
clearerr
, clearerr_unlocked
—clear file or stream error indicatordiprintf
, vdiprintf
—print to a file descriptor (integer only)dprintf
, vdprintf
—print to a file descriptorfclose
—close a filefcloseall
—close all filesfdopen
—turn open file into a streamfeof
, feof_unlocked
—test for end of fileferror
, ferror_unlocked
—test whether read/write error has occurredfflush
, fflush_unlocked
—flush buffered file outputfgetc
, fgetc_unlocked
—get a character from a file or streamfgetpos
—record position in a stream or filefgets
, fgets_unlocked
—get character string from a file or streamfgetwc
, getwc
, fgetwc_unlocked
, getwc_unlocked
—get a wide character from a file or streamfgetws
, fgetws_unlocked
—get wide character string from a file or streamfileno
, fileno_unlocked
—return file descriptor associated with streamfmemopen
—open a stream around a fixed-length stringfopen
—open a filefopencookie
—open a stream with custom callbacksfpurge
—discard pending file I/Ofputc
, fputc_unlocked
—write a character on a stream or filefputs
, fputs_unlocked
—write a character string in a file or streamfputwc
, putwc
, fputwc_unlocked
, putwc_unlocked
—write a wide character on a stream or filefputws
, fputws_unlocked
—write a wide character string in a file or streamfread
, fread_unlocked
—read array elements from a filefreopen
—open a file using an existing file descriptorfseek
, fseeko
—set file position__fsetlocking
—set or query locking mode on FILE streamfsetpos
—restore position of a stream or fileftell
, ftello
—return position in a stream or filefunopen
, fropen
, fwopen
—open a stream with custom callbacksfwide
—set and determine the orientation of a FILE streamfwrite
, fwrite_unlocked
—write array elementsgetc
—read a character (macro)getc_unlocked
—non-thread-safe version of getc (macro)getchar
—read a character (macro)getchar_unlocked
—non-thread-safe version of getchar (macro)getdelim
—read a line up to a specified line delimitergetline
—read a line from a filegets
—get character string (obsolete, use fgets
instead)getw
—read a word (int)getwchar
, getwchar_unlocked
—read a wide character from standard inputmktemp
, mkstemp
, mkostemp
, mkstemps
,open_memstream
, open_wmemstream
—open a write stream around an arbitrary-length stringperror
—print an error message on standard errorputc
—write a character (macro)putc_unlocked
—non-thread-safe version of putc (macro)putchar
—write a character (macro)putchar_unlocked
—non-thread-safe version of putchar (macro)puts
—write a character stringputw
—write a word (int)putwchar
, putwchar_unlocked
—write a wide character to standard outputremove
—delete a file’s namerename
—rename a filerewind
—reinitialize a file or streamsetbuf
—specify full buffering for a file or streamsetbuffer
—specify full buffering for a file or stream with sizesetlinebuf
—specify line buffering for a file or streamsetvbuf
—specify file or stream bufferingsiprintf
, fiprintf
, iprintf
, sniprintf
, asiprintf
, asniprintf
—format output (integer only)siscanf
, fiscanf
, iscanf
—scan and format non-floating inputsprintf
, fprintf
, printf
, snprintf
, asprintf
, asnprintf
—format outputsscanf
, fscanf
, scanf
—scan and format inputstdio_ext
,__fbufsize
,__fpending
,__flbf
,__freadable
,__fwritable
,__freading
,__fwriting
—access internals of FILE structureswprintf
, fwprintf
, wprintf
—wide character format outputswscanf
, fwscanf
, wscanf
—scan and format wide character inputtmpfile
—create a temporary filetmpnam
, tempnam
—name for a temporary fileungetc
—push data back into a streamungetwc
—push wide character data back into a streamvfprintf
, vprintf
, vsprintf
, vsnprintf
, vasprintf
, vasnprintf
—format argument listvfscanf
, vscanf
, vsscanf
—format argument listvfwprintf
, vwprintf
, vswprintf
—wide character format argument listvfwscanf
, vwscanf
, vswscanf
—scan and format argument list from wide character inputviprintf
, vfiprintf
, vsiprintf
, vsniprintf
, vasiprintf
, vasniprintf
—format argument list (integer only)viscanf
, vfiscanf
, vsiscanf
—format argument list