Resets the error flags and the EOF indicator for the given file stream.
Resets the error flags and the EOF indicator for the given file stream.
the file to reset the error flags for
Closes the given file stream.
Closes the given file stream. Any unwritten buffered data are flushed to the OS. Any unread buffered data are discarded.
Whether or not the operation succeeds, the stream is no longer associated with a file, and the buffer allocated by setbuf or setvbuf, if any, is also disassociated and deallocated if automatic allocation was used.
The behavior is undefined if the value of the pointer stream is used after fclose returns.
the file stream to close
0 on success, EOF otherwise
Checks if the end of the given file stream has been reached.
Checks if the end of the given file stream has been reached.
the file stream to check
nonzero value if the end of the stream has been reached, otherwise 0
Checks the given stream for errors.
Checks the given stream for errors.
the file stream to check
Nonzero value if the file stream has errors occurred, 0 otherwise
For output streams (and for update streams on which the last operation was output), writes any unwritten data from the stream's buffer to the associated output device.
For output streams (and for update streams on which the last operation was output), writes any unwritten data from the stream's buffer to the associated output device.
For input streams (and for update streams on which the last operation was input), the behavior is undefined.
If stream is a null pointer, all open output streams are flushed, including the ones manipulated within library packages or otherwise not directly accessible to the program.
the file stream to write out
0 on success. Otherwise EOF is returned and the error indicator of the file stream is set.
Reads the next character from the given input stream.
Reads the next character from the given input stream.
stream to read the character from
Return value On success, returns the obtained character as an unsigned char converted to an int. On failure, returns EOF. If the failure has been caused by end-of-file condition, additionally sets the eof indicator (see feof()) on stream. If the failure has been caused by some other error, sets the error indicator (see ferror()) on stream.
Retrieves the current position in the stream.
Retrieves the current position in the stream.
Pointer to a FILE object that identifies the stream.
0 on success. non-zero value on failure and errno is set.
Reads at most count - 1 characters from the given file stream and stores them in the character array pointed to by str.
Reads at most count - 1 characters from the given file stream and stores them in the character array pointed to by str. Parsing stops if a newline character is found, in which case str will contain that newline character, or if end-of-file occurs. If bytes are read and no errors occur, writes a null character at the position immediately after the last character written to str.
pointer to an element of a char array
maximum number of characters to write (typically the length of str)
file stream to read the data from
str on success, null pointer on failure. If the end-of-file condition is encountered, sets the eof indicator on stream (see feof()). This is only a failure if it causes no bytes to be read, in which case a null pointer is returned and the contents of the array pointed to by str are not altered (i.e. the first byte is not overwritten with a null character). If the failure has been caused by some other error, sets the error indicator (see ferror()) on stream. The contents of the array pointed to by str are indeterminate (it may not even be null-terminated).
Opens a file indicated by filename and returns a file stream associated with that file.
Opens a file indicated by filename and returns a file stream associated with that file. mode is used to determine the file access mode.
If successful, returns a pointer to the object that controls the opened file stream, with both eof and error bits cleared. The stream is fully buffered unless filename refers to an interactive device.
Writes a character ch to the given output stream stream.
Writes a character ch to the given output stream stream. putc() may be implemented as a macro and evaluate stream more than once, so the corresponding argument should never be an expression with side effects.
Internally, the character is converted to unsigned char just before being written.
character to be written
output stream
On success, returns the written character. On failure, returns EOF and sets the error indicator (see ferror()) on stream.
Writes every character from the null-terminated string str to the output stream stream, as if by repeatedly executing fputc.
Writes every character from the null-terminated string str to the output stream stream, as if by repeatedly executing fputc.
The terminating null character from str is not written.
null-terminated character string to be written
output stream
non-negative value on success. Otherwise, returns EOF and sets the error indicator (see ferror()) on stream.
Reads up to count objects into the array buffer from the given input stream stream as if by calling fgetc size times for each object, and storing the results, in the order obtained, into the successive positions of buffer, which is reinterpreted as an array of unsigned char.
Reads up to count objects into the array buffer from the given input stream stream as if by calling fgetc size times for each object, and storing the results, in the order obtained, into the successive positions of buffer, which is reinterpreted as an array of unsigned char. The file position indicator for the stream is advanced by the number of characters read.
If an error occurs, the resulting value of the file position indicator for the stream is indeterminate. If a partial element is read, its value is indeterminate.
pointer to the array where the read objects are stored
size of each object in bytes
the number of the objects to be read
the stream to read
Number of objects read successfully, which may be less than count if an error or end-of-file condition occurs. If size or count is zero, fread returns zero and performs no other action. fread does not distinguish between end-of-file and error, and callers must use feof and ferror to determine which occurred.
Sets the position indicator associated with the stream to a new position.
Sets the position indicator associated with the stream to a new position.
Pointer to a FILE object that identifies the stream.
\- Binary files: Number of bytes to offset from origin. \- Text files: Either zero, or a value returned by ftell.
Position used as reference for the offset. It is specified by one of the following constants defined in <cstdio> exclusively to be used as arguments for this function: | Constant | Reference position | |:---------|:-------------------------------------| | SEEK_SET | Beginning of file | | SEEK_CUR | Current position of the file pointer | | SEEK_END | End of file(1) | (1). Library implementations are allowed to not meaningfully support SEEK_END (therefore, code using it has no real standard portability).
0 on success, non-zero value on failure.
Restores the current position in the stream to pos.
Restores the current position in the stream to pos.
Pointer to a FILE object that identifies the stream.
0 on success. Non-zero value on failure.
Returns the current value of the position indicator of the stream.
Returns the current value of the position indicator of the stream.
Pointer to a FILE object that identifies the stream.
the current value of the position indicator is returned on success. -1L on Failure and errno is set to system-specific positive value.
If mode > 0, attempts to make stream wide-oriented.
If mode > 0, attempts to make stream wide-oriented. If mode < 0, attempts to make stream byte-oriented. If mode==0, only queries the current orientation of the stream.
If the orientation of the stream has already been decided (by executing output or by an earlier call to fwide), this function does nothing.
pointer to the C I/O stream to modify or query
integer value greater than zero to set the stream wide, less than zero to set the stream narrow, or zero to query only
An integer greater than zero if the stream is wide-oriented after this call, less than zero if the stream is byte-oriented after this call, and zero if the stream has no orientation.
Writes count of objects from the given array buffer to the output stream stream.
Writes count of objects from the given array buffer to the output stream stream. The objects are written as if by reinterpreting each object as an array of unsigned char and calling fputc size times for each object to write those unsigned chars into stream, in order. The file position indicator for the stream is advanced by the number of characters written.
If an error occurs, the resulting value of the file position indicator for the stream is indeterminate.
pointer to the first object in the array to be written
size of each object
the number of the objects to be written
pointer to the output stream
The number of objects written successfully, which may be less than count if an error occurs.If size or count is zero, fwrite returns zero and performs no other action.
Same as fgetc, except that if getc is implemented as a macro, it may evaluate stream more than once, so the corresponding argument should never be an expression with side effects.
Same as fgetc, except that if getc is implemented as a macro, it may evaluate stream more than once, so the corresponding argument should never be an expression with side effects.
stream to read the character from
Return value On success, returns the obtained character as an unsigned char converted to an int. On failure, returns EOF. If the failure has been caused by end-of-file condition, additionally sets the eof indicator (see feof()) on stream. If the failure has been caused by some other error, sets the error indicator (see ferror()) on stream.
Reads the next character from stdin.
Reads the next character from stdin.
The obtained character on success or EOF on failure. If the failure has been caused by end-of-file condition, additionally sets the eof indicator (see feof()) on stdin. If the failure has been caused by some other error, sets the error indicator (see ferror()) on stdin.
Reads stdin into given character string until a newline character is found or end-of-file occurs.
Reads stdin into given character string until a newline character is found or end-of-file occurs.
character string to be written
str on success, a null pointer on failure. If the failure has been caused by end of file condition, additionally sets the eof indicator (see std::feof()) on stdin. If the failure has been caused by some other error, sets the error indicator (see std::ferror()) on stdin.
Prints a textual description of the error code currently stored in the system variable errno to stderr.
Prints a textual description of the error code currently stored in the system variable errno to stderr.
pointer to a null-terminated string with explanatory message.
Writes a character ch to the given output stream stream.
Writes a character ch to the given output stream stream. putc() may be implemented as a macro and evaluate stream more than once, so the corresponding argument should never be an expression with side effects.
Internally, the character is converted to unsigned char just before being written.
character to be written
output stream
On success, returns the written character. On failure, returns EOF and sets the error indicator (see ferror()) on stream.
Writes a character ch to stdout.
Writes a character ch to stdout. Internally, the character is converted to unsigned char just before being written.
character to be written
the written character on success. Otherwise return EOF and sets the error indicator on stdout.
https://en.cppreference.com/w/c/io/ferror for error indicators.
Writes every character from the null-terminated string str and one additional newline character '\n' to the output stream stdout, as if by repeatedly executing fputc.
Writes every character from the null-terminated string str and one additional newline character '\n' to the output stream stdout, as if by repeatedly executing fputc.
The terminating null character from str is NOT written.
character string to be written
a non-negative value on success. Otherwise, return EOF and sets the error indicator on stream.
https://en.cppreference.com/w/c/io/ferror for error indicators.
Deletes the file identified by character string pointed to by fname.
Deletes the file identified by character string pointed to by fname.
pointer to a null-terminated string containing the path identifying the file to delete
0 upon success or non-zero value on error.
Changes the filename of a file.
Changes the filename of a file. The file is identified by character string pointed to by old_filename. The new filename is identified by character string pointed to by new_filename.
If new_filename exists, the behavior is implementation-defined.
0 upon success or non-zero value on error.
Sets the position indicator associated with stream to the beginning of the file.
Sets the position indicator associated with stream to the beginning of the file.
pointer to a FILE object that identifies the stream.
Sets the internal buffer to use for stream operations.
Sets the internal buffer to use for stream operations. It should be at least BUFSIZ characters long.
the file stream to set the buffer to
pointer to a buffer for the stream to use. If a null pointer is supplied, the buffering is turned off
Changes the buffering mode of the given file stream stream as indicated by the argument mode.
Changes the buffering mode of the given file stream stream as indicated by the argument mode. In addition,
the file stream to set the buffer to
pointer to a buffer for the stream to use or null pointer to change size and mode only
buffering mode to use. It can be one of the following values: | mode | buffer | |:-------|:---------------| | _IOFBF | full buffering | | _IOLBF | line buffering | | _IONBF | no buffering |
0 on success or nonzero on failure.
Creates and opens a temporary file with a unique auto-generated filename.
Creates and opens a temporary file with a unique auto-generated filename.
The associated file stream or a null pointer if an error has occurred
Creates a unique filename that does not name a currently existing file, and stores it in the character string pointed to by filename.
Creates a unique filename that does not name a currently existing file, and stores it in the character string pointed to by filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may already be in use, and thus not suitable return values.
filename if filename was not a null pointer. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, a null pointer is returned.
If ch does not equal EOF, pushes the character ch (reinterpreted as unsigned char) into the input buffer associated with the stream stream in such a manner that subsequent read operation from stream will retrieve that character.
If ch does not equal EOF, pushes the character ch (reinterpreted as unsigned char) into the input buffer associated with the stream stream in such a manner that subsequent read operation from stream will retrieve that character. The external device associated with the stream is not modified.
Stream repositioning operations fseek, fsetpos, and rewind discard the effects of ungetc.
If ungetc is called more than once without an intervening read or repositioning, it may fail (in other words, a pushback buffer of size 1 is guaranteed, but any larger buffer is implementation-defined). If multiple successful ungetc were performed, read operations retrieve the pushed-back characters in reverse order of ungetc.
If ch equals EOF, the operation fails and the stream is not affected.
A successful call to ungetc clears the end of file status flag feof.
A successful call to ungetc on a binary stream decrements the stream position indicator by one (the behavior is indeterminate if the stream position indicator was zero).
A successful call to ungetc on a text stream modifies the stream position indicator in unspecified manner but guarantees that after all pushed-back characters are retrieved with a read operation, the stream position indicator is equal to its value before ungetc.
character to be pushed into the input stream buffer
file stream to put the character back to
ch on success. Otherwise returns EOF and the given stream remains unchanged.
Writes the results to a file stream stream.
Writes the results to a file stream stream.
output file stream to write to
pointer to a null-terminated character string specifying how to interpret the data
The number of characters written if successful or negative value if an error occurred.
Read formatted data from stream into variable argument list Reads data from the stream and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.
Read formatted data from stream into variable argument list Reads data from the stream and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.
Pointer to a FILE object that identifies an input stream.
C string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
A value identifying a variable arguments list initialized with va_start. va_list is a special type defined in <cstdarg>.
the number of items of the argument listsuccessfully filled on success. If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.
Writes the results to stdout.
Writes the results to stdout.
pointer to a null-terminated character string specifying how to interpret the data
variable argument list containing the data to print.
The number of characters written if successful or negative value if an error occurred.
Read formatted data into variable argument list Reads data from the standard input (stdin) and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.
Read formatted data into variable argument list Reads data from the standard input (stdin) and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.
C string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
A value identifying a variable arguments list initialized with va_start. va_list is a special type defined in <cstdarg>.
the number of items of the argument listsuccessfully filled on success. If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.
The number of characters written if successful or negative value if an error occurred.
The number of characters written if successful or negative value if an error occurred. If the resulting string gets truncated due to buf_size limit, function returns the total number of characters (not including the terminating null-byte) which would have been written, if the limit was not imposed. *
pointer to a character string to write to
up to bufsz - 1 characters may be written, plus the null terminator
pointer to a null-terminated character string specifying how to interpret the data
The number of characters written if successful or negative value if an error occurred.
Writes the results to a character string buffer.
Writes the results to a character string buffer.
pointer to a character string to write to
pointer to a null-terminated character string specifying how to interpret the data
The number of characters written if successful or negative value if an error occurred.
Reads the data from stdin
Reads the data from stdin
pointer to a null-terminated character string to read from
pointer to a null-terminated character string specifying how to read the input
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned