📄 stdio.h
字号:
/*
* is equivalent to fgetc except that it may be implemented as an unsafe
* macro (stream may be evaluated more than once, so the argument should
* never be an expression with side-effects).
* 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 getc returns EOF. If a read error occurs, the error
* indicator is set and getc returns EOF.
*/
#define getchar() getc(stdin)
extern int (getchar)(void);
/*
* is equivalent to getc with the argument stdin.
* Returns: the next character from the input stream pointed to by stdin.
* If the stream is at end-of-file, the end-of-file indicator is
* set and getchar returns EOF. If a read error occurs, the error
* indicator is set and getchar returns EOF.
*/
extern char *gets(char * /*s*/);
/*
* reads characters from the input stream pointed to by stdin into the array
* pointed to by s, until end-of-file is encountered or a new-line character
* is read. Any new-line character is discarded, and 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 putc(int /*c*/, FILE * /*stream*/);
/*
* is equivalent to fputc except that it may be implemented as aan unsafe
* macro (stream may be evaluated more than once, so the argument should
* never be an expression with side-effects).
* Returns: the character written. If a write error occurs, the error
* indicator is set and putc returns EOF.
*/
#define putchar(ch) putc(ch, stdout)
extern int (putchar)(int /*c*/);
/*
* is equivalent to putc with the second argument stdout.
* Returns: the character written. If a write error occurs, the error
* indicator is set and putc returns EOF.
*/
extern int puts(const char * /*s*/);
/*
* writes the string pointed to by s to the stream pointed to by stdout, and
* appends a new-line character to the output. The terminating null
* character is not written.
* Returns: EOF if a write error occurs; otherwise it returns a nonnegative
* value.
*/
extern int ungetc(int /*c*/, FILE * /*stream*/);
/*
* pushes the character specified by c (converted to an unsigned char) back
* onto the input stream pointed to by stream. The character will be
* returned by the next read on that stream. An intervening call to the
* fflush function or to a file positioning function (fseek, fsetpos,
* rewind) discards any pushed-back characters. The external storage
* corresponding to the stream is unchanged.
* One character pushback is guaranteed. If the unget function is called too
* many times on the same stream without an intervening read or file
* positioning operation on that stream, the operation may fail.
* If the value of c equals that of the macro EOF, the operation fails and
* the input stream is unchanged.
* A successful call to the ungetc function clears the end-of-file
* indicator. The value of the file position indicator after reading or
* discarding all pushed-back characters shall be the same as it was before
* the characters were pushed back. For a text stream, the value of the file
* position indicator after a successful call to the ungetc function is
* unspecified until all pushed-back characters are read or discarded. For a
* binary stream, the file position indicator is decremented by each
* successful call to the ungetc function; if its value was zero before a
* call, it is indeterminate after the call.
* Returns: the character pushed back after conversion, or EOF if the
* operation fails.
*/
extern size_t fread(void * /*ptr*/,
size_t /*size*/, size_t /*nmemb*/, FILE * /*stream*/);
/*
* reads into the array pointed to by ptr, up to nmemb members whose size is
* specified by size, from the stream pointed to by stream. The file
* position indicator (if defined) is advanced by the number of characters
* successfully read. If an error occurs, the resulting value of the file
* position indicator is indeterminate. If a partial member is read, its
* value is indeterminate. The ferror or feof function shall be used to
* distinguish between a read error and end-of-file.
* Returns: the number of members successfully read, which may be less than
* nmemb if a read error or end-of-file is encountered. If size or
* nmemb is zero, fread returns zero and the contents of the array
* and the state of the stream remain unchanged.
*/
extern size_t fwrite(const void * /*ptr*/,
size_t /*size*/, size_t /*nmemb*/, FILE * /*stream*/);
/*
* writes, from the array pointed to by ptr up to nmemb members whose size
* is specified by size, to the stream pointed to by stream. The file
* position indicator (if defined) is advanced by the number of characters
* successfully written. If an error occurs, the resulting value of the file
* position indicator is indeterminate.
* Returns: the number of members successfully written, which will be less
* than nmemb only if a write error is encountered.
*/
extern int fgetpos(FILE * /*stream*/, fpos_t * /*pos*/);
/*
* stores the current value of the file position indicator for the stream
* pointed to by stream in the object pointed to by pos. The value stored
* contains unspecified information usable by the fsetpos function for
* repositioning the stream to its position at the time of the call to the
* fgetpos function.
* Returns: zero, if successful. Otherwise nonzero is returned and the
* integer expression errno is set to an implementation-defined
* nonzero value (under RISCOS/Arthur/Brazil fgetpos cannot fail).
*/
extern int fseek(FILE * /*stream*/, long int /*offset*/, int /*whence*/);
/*
* sets the file position indicator for the stream pointed to by stream.
* For a binary stream, the new position is at the signed number of
* characters specified by offset away from the point specified by whence.
* The specified point is the beginning of the file for SEEK_SET, the
* current position in the file for SEEK_CUR, or end-of-file for SEEK_END.
* A binary stream need not meaningfully support fseek calls with a whence
* value of SEEK_END.
* For a text stream, either offset shall be zero, or offset shall be a
* value returned by an earlier call to the ftell function on the same
* stream and whence shall be SEEK_SET.
* The fseek function clears the end-of-file indicator and undoes any
* effects of the ungetc function on the same stream. After an fseek call,
* the next operation on an update stream may be either input or output.
* Returns: nonzero only for a request that cannot be satisfied.
*/
extern int fsetpos(FILE * /*stream*/, const fpos_t * /*pos*/);
/*
* sets the file position indicator for the stream pointed to by stream
* according to the value of the object pointed to by pos, which shall be a
* value returned by an earlier call to the fgetpos function on the same
* stream.
* The fsetpos function clears the end-of-file indicator and undoes any
* effects of the ungetc function on the same stream. After an fsetpos call,
* the next operation on an update stream may be either input or output.
* Returns: zero, if successful. Otherwise nonzero is returned and the
* integer expression errno is set to an implementation-defined
* nonzero value (under RISCOS/Arthur/Brazil the value that of EDOM
* in math.h).
*/
extern long int ftell(FILE * /*stream*/);
/*
* obtains the current value of the file position indicator for the stream
* pointed to by stream. For a binary stream, the value is the number of
* characters from the beginning of the file. For a text stream, the file
* position indicator contains unspecified information, usable by the fseek
* function for returning the file position indicator to its position at the
* time of the ftell call; the difference between two such return values is
* not necessarily a meaningful measure of the number of characters written
* or read.
* Returns: if successful, the current value of the file position indicator.
* On failure, the ftell function returns -1L and sets the integer
* expression errno to an implementation-defined nonzero value
* (under RISCOS/Arthur/Brazil ftell cannot fail).
*/
extern void rewind(FILE * /*stream*/);
/*
* sets the file position indicator for the stream pointed to by stream to
* the beginning of the file. It is equivalent to
* (void)fseek(stream, 0L, SEEK_SET)
* except that the error indicator for the stream is also cleared.
* Returns: no value.
*/
extern void clearerr(FILE * /*stream*/);
/*
* clears the end-of-file and error indicators for the stream pointed to by
* stream. These indicators are cleared only when the file is opened or by
* an explicit call to the clearerr function or to the rewind function.
* Returns: no value.
*/
extern int feof(FILE * /*stream*/);
/*
* tests the end-of-file indicator for the stream pointed to by stream.
* Returns: nonzero iff the end-of-file indicator is set for stream.
*/
extern int ferror(FILE * /*stream*/);
/*
* tests the error indicator for the stream pointed to by stream.
* Returns: nonzero iff the error indicator is set for stream.
*/
extern void perror(const char * /*s*/);
/*
* maps the error number in the integer expression errno to an error
* message. It writes a sequence of characters to the standard error stream
* thus: first (if s is not a null pointer and the character pointed to by
* s is not the null character), the string pointed to by s followed by a
* colon and a space; then an appropriate error message string followed by
* a new-line character. The contents of the error message strings are the
* same as those returned by the strerror function with argument errno,
* which are implementation-defined.
* Returns: no value.
*/
#ifdef __cplusplus
}
#endif
#endif
/* end of stdio.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -