Wednesday, August 31, 2016

C Library Header – stdio

The <stdio.h> header provides functions for performing input and output.

The <stdio.h> header shall define the following macro constant:
EOFA negative integer of type int used to indicate end-of-file conditions
BUFSIZAn integer which is the size of the buffer used by the setbuf() function
FILENAME_MAX The size of a char array which is large enough to store the name of any file that can be opened
FOPEN_MAX The number of files that may be open simultaneously; will be at least eight
_IOFBF An abbreviation for "input/output fully buffered"; it is an integer which may be passed to the setvbuf() function to request block buffered input and output for an open stream
_IOLBF An abbreviation for "input/output line buffered"; it is an integer which may be passed to the setvbuf() function to request line buffered input and output for an open stream
_IONBF An abbreviation for "input/output not buffered"; it is an integer which may be passed to the setvbuf() function to request unbuffered input and output for an open stream
stdin expression of type FILE* associated with the input stream
stdout expression of type FILE* associated with the output stream
stderr expression of type FILE* associated with the error output stream
NULL A macro expanding to the null pointer constant; that is, a constant representing a pointer value which is guaranteed not to be a valid address of an object in memory
SEEK_CUR An integer which may be passed to the fseek() function to request positioning relative to the current file position
SEEK_END An integer which may be passed to the fseek() function to request positioning relative to the end of the file
SEEK_SET An integer which may be passed to the fseek() function to request positioning relative to the beginning of the file
TMP_MAX The maximum number of unique filenames generable by the tmpnam() function; will be at least 25
TMP_MAX_S maximum number of unique filenames that can be generated by tmpnam_s(C11)
L_tmpnam The size of a char array which is large enough to store a temporary filename generated by the tmpnam() function
L_tmpnam_s size needed for an array of char to hold the result of tmpnam_s

The <stdio.h> header shall define the following functions:
Operations on files:
removeerases a file
renamerenames a file
tmpfile
tmpfile_s
returns a pointer to a temporary file (C11)
tmpnam
tmpnam_s
returns a unique filename (C11)

File access:
fopen
fopen_s(C11)
opens a file 
freopen
freopen_s(C11)
open an existing stream with a different name
fclosecloses a file
fflushsynchronizes an output stream with the actual file
setbufsets the buffer for a file stream
setvbufsets the buffer and its size for a file stream

Formatted input/output:
scanf
fscanf
sscanf
scanf_s(C11)
fscanf_s(C11)
sscanf_s(C11)
reads formatted input from stdin, a file stream or a buffer
vscanf(C99)
vfscanf(C99)
vsscanf(C99)
vscanf_s(C11)
vfscanf_s(C11)
vsscanf_s(C11)
reads formatted input from stdin, a file stream or a buffer using variable argument list
printf
fprintf
sprint
snprintf(C99)
printf_s(C11)
fprintf_s(C11)
sprintf_s(C11)
snprintf_s(C11)
prints formatted output to stdout, a file stream or a buffer
vprintf
vfprintf
vsprintf
vsnprintf(C99)
vprintf_s(C11)
vfprintf_s(C11)
vsprintf_s(C11)
vsnprintf_s(C11)
prints formatted output to stdout, a file stream or a buffer using variable argument list

Character input/output:
fgetc
getc
gets a character from a file stream
fgetsgets a character string from a file stream
fputc
putc
writes a character to a file stream
fputswrites a character string to a file stream
getcharreads a character from stdin
gets
gets_s(C11)
reads a character string from stdin
putcharwrites a character to stdout
putswrites a character string to stdout
ungetcputs a character back into a file stream

Direct input/output:
freadreads from a file
fwritewrites to a file

File positioning:
ftellreturns the current file position indicator
fgetposgets the file position indicator
fseekmoves the file position indicator to a specific location in a file
fsetposmoves the file position indicator to a specific location in a file
rewindmoves the file position indicator to the beginning in a file

Error-handling:
clearerrclears errors
feofchecks for the end-of-file
ferrorchecks for a file error
perrordisplays a character string corresponding of the current error to stderr

The <stdio.h> header shall define the following type:
FILE type, capable of holding all information needed to control a C I/O stream
fpos_t type, capable of uniquely specifying a position and mutibyte parser state in a file
size_tUnsigned integral type



Related topics:
<setdef.h>   |   <stdint.h>   |   <stdlib.h>   |   <stdnoreturn.h>   |   <string.h>   |   Standard Library in C

List of topics: C Programming

No comments:

Post a Comment