📄 stdio.h
字号:
* positioning function (fseek, fsetpos, or rewind), and input be not be
* directly followed by output without an intervening call to the fflush
* fuction or to a file positioning function, unless the input operation
* encounters end-of-file. Opening a file with update mode may open or
* create a binary stream in some implementations (but not under RISCOS/
* Arthur/Brazil). When opened, a stream is fully buffered if and only if
* it does not refer to an interactive device. The error and end-of-file
* indicators for the stream are cleared.
* Returns: a pointer to the object controlling the stream. If the open
* operation fails, fopen returns a null pointer.
*/
extern FILE *freopen(const char * /*filename*/, const char * /*mode*/,
FILE * /*stream*/);
/*
* opens the file whose name is the string pointed to by filename and
* associates the stream pointed to by stream with it. The mode argument is
* used just as in the fopen function.
* The freopen function first attempts to close any file that is associated
* with the specified stream. Failure to close the file successfully is
* ignored. The error and end-of-file indicators for the stream are cleared.
* Returns: a null pointer if the operation fails. Otherwise, freopen
* returns the value of the stream.
*/
extern void setbuf(FILE * /*stream*/, char * /*buf*/);
/*
* Except that it returns no value, the setbuf function is equivalent to the
* setvbuf function invoked with the values _IOFBF for mode and BUFSIZ for
* size, or (if buf is a null pointer), with the value _IONBF for mode.
* Returns: no value.
*/
extern int setvbuf(FILE * /*stream*/, char * /*buf*/,
int /*mode*/, size_t /*size*/);
/*
* may be used after the stream pointed to by stream has been associated
* with an open file but before it is read or written. The argument mode
* determines how stream will be buffered, as follows: _IOFBF causes
* input/output to be fully buffered; _IOLBF causes output to be line
* buffered (the buffer will be flushed when a new-line character is
* written, when the buffer is full, or when input is requested); _IONBF
* causes input/output to be completely unbuffered. If buf is not the null
* pointer, the array it points to may be used instead of an automatically
* allocated buffer (the buffer must have a lifetime at least as great as
* the open stream, so the stream should be closed before a buffer that has
* automatic storage duration is deallocated upon block exit). The argument
* size specifies the size of the array. The contents of the array at any
* time are indeterminate.
* Returns: zero on success, or nonzero if an invalid value is given for
* mode or size, or if the request cannot be honoured.
*/
#pragma -v1 /* hint to the compiler to check f/s/printf format */
extern int fprintf(FILE * /*stream*/, const char * /*format*/, ...);
/*
* writes output to the stream pointed to by stream, under control of the
* string pointed to by format that specifies how subsequent arguments are
* converted for output. If there are insufficient arguments for the format,
* the behaviour is undefined. If the format is exhausted while arguments
* remain, the excess arguments are evaluated but otherwise ignored. The
* fprintf function returns when the end of the format string is reached.
* The format shall be a multibyte character sequence, beginning and ending
* in its initial shift state. The format is composed of zero or more
* directives: ordinary multibyte characters (not %), which are copied
* unchanged to the output stream; and conversion specifiers, each of which
* results in fetching zero or more subsequent arguments. Each conversion
* specification is introduced by the character %. For a description of the
* available conversion specifiers refer to section 4.9.6.1 in the ANSI
* draft mentioned at the start of this file or to any modern textbook on C.
* The minimum value for the maximum number of characters producable by any
* single conversion is at least 509.
* Returns: the number of characters transmitted, or a negative value if an
* output error occurred.
*/
extern int printf(const char * /*format*/, ...);
/*
* is equivalent to fprintf with the argument stdout interposed before the
* arguments to printf.
* Returns: the number of characters transmitted, or a negative value if an
* output error occurred.
*/
extern int sprintf(char * /*s*/, const char * /*format*/, ...);
/*
* is equivalent to fprintf, except that the argument s specifies an array
* into which the generated output is to be written, rather than to a
* stream. A null character is written at the end of the characters written;
* it is not counted as part of the returned sum.
* Returns: the number of characters written to the array, not counting the
* terminating null character.
*/
#pragma -v2 /* hint to the compiler to check f/s/scanf format */
extern int fscanf(FILE * /*stream*/, const char * /*format*/, ...);
/*
* reads input from the stream pointed to by stream, under control of the
* string pointed to by format that specifies the admissible input sequences
* and how thay are to be converted for assignment, using subsequent
* arguments as pointers to the objects to receive the converted input. If
* there are insufficient arguments for the format, the behaviour is
* undefined. If the format is exhausted while arguments remain, the excess
* arguments are evaluated but otherwise ignored.
* The format is composed of zero or more directives: one or more
* white-space characters; an ordinary character (not %); or a conversion
* specification. Each conversion specification is introduced by the
* character %. For a description of the available conversion specifiers
* refer to section 4.9.6.2 in the ANSI draft mentioned at the start of this
* file, or to any modern textbook on C.
* If end-of-file is encountered during input, conversion is terminated. If
* end-of-file occurs before any characters matching the current directive
* have been read (other than leading white space, where permitted),
* execution of the current directive terminates with an input failure;
* otherwise, unless execution of the current directive is terminated with a
* matching failure, execution of the following directive (if any) is
* terminated with an input failure.
* If conversions terminates on a conflicting input character, the offending
* input character is left unread in the input strem. Trailing white space
* (including new-line characters) is left unread unless matched by a
* directive. The success of literal matches and suppressed asignments is
* not directly determinable other than via the %n directive.
* Returns: the value of the macro EOF if an input failure occurs before any
* conversion. Otherwise, the fscanf function returns the number of
* input items assigned, which can be fewer than provided for, or
* even zero, in the event of an early conflict between an input
* character and the format.
*/
extern int scanf(const char * /*format*/, ...);
/*
* is equivalent to fscanf with the argument stdin interposed before the
* arguments to scanf.
* Returns: the value of the macro EOF if an input failure occurs before any
* conversion. Otherwise, the scanf function returns the number of
* input items assigned, which can be fewer than provided for, or
* even zero, in the event of an early matching failure.
*/
extern int sscanf(const char * /*s*/, const char * /*format*/, ...);
/*
* is equivalent to fscanf except that the argument s specifies a string
* from which the input is to be obtained, rather than from a stream.
* Reaching the end of the string is equivalent to encountering end-of-file
* for the fscanf function.
* Returns: the value of the macro EOF if an input failure occurs before any
* conversion. Otherwise, the scanf function returns the number of
* input items assigned, which can be fewer than provided for, or
* even zero, in the event of an early matching failure.
*/
#pragma -v0 /* back to default */
extern int vprintf(const char * /*format*/, __va_list /*arg*/);
/*
* is equivalent to printf, with the variable argument list replaced by arg,
* which has been initialised by the va_start macro (and possibly subsequent
* va_arg calls). The vprintf function does not invoke the va_end function.
* Returns: the number of characters transmitted, or a negative value if an
* output error occurred.
*/
extern int vfprintf(FILE * /*stream*/,
const char * /*format*/, __va_list /*arg*/);
/*
* is equivalent to fprintf, with the variable argument list replaced by
* arg, which has been initialised by the va_start macro (and possibly
* subsequent va_arg calls). The vfprintf function does not invoke the
* va_end function.
* Returns: the number of characters transmitted, or a negative value if an
* output error occurred.
*/
extern int vsprintf(char * /*s*/, const char * /*format*/, __va_list /*arg*/);
/*
* is equivalent to sprintf, with the variable argument list replaced by
* arg, which has been initialised by the va_start macro (and possibly
* subsequent va_arg calls). The vsprintf function does not invoke the
* va_end function.
* Returns: the number of characters written in the array, not counting the
* terminating null character.
*/
extern int fgetc(FILE * /*stream*/);
/*
* obtains the next character (if present) as an unsigned char converted to
* an int, from the input stream pointed to by stream, and advances the
* associated file position indicator (if defined).
* Returns: the next character from the input stream pointed to by stream.
* If the stream is at end-of-file, the end-of-file indicator is
* set and fgetc returns EOF. If a read error occurs, the error
* indicator is set and fgetc returns EOF.
*/
extern char *fgets(char * /*s*/, int /*n*/, FILE * /*stream*/);
/*
* reads at most one less than the number of characters specified by n from
* the stream pointed to by stream into the array pointed to by s. No
* additional characters are read after a new-line character (which is
* retained) or after end-of-file. A null character is written immediately
* after the last character read into the array.
* Returns: s if successful. If end-of-file is encountered and no characters
* have been read into the array, the contents of the array remain
* unchanged and a null pointer is returned. If a read error occurs
* during the operation, the array contents are indeterminate and a
* null pointer is returned.
*/
extern int fputc(int /*c*/, FILE * /*stream*/);
/*
* writes the character specified by c (converted to an unsigned char) to
* the output stream pointed to by stream, at the position indicated by the
* asociated file position indicator (if defined), and advances the
* indicator appropriately. If the file position indicator is not defined,
* the character is appended to the output stream.
* Returns: the character written. If a write error occurs, the error
* indicator is set and fputc returns EOF.
*/
extern int fputs(const char * /*s*/, FILE * /*stream*/);
/*
* writes the string pointed to by s to the stream pointed to by stream.
* The terminating null character is not written.
* Returns: EOF if a write error occurs; otherwise it returns a nonnegative
* value.
*/
extern int getc(FILE * /*stream*/);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -