I/O

int FClose(
    FILE * fFile)


Returns 0 if the stream is successfully closed. All streams created by a thread are closed automatically when the thread exits.


int FEof(
    FILE * fFile)


Returns a nonzero value after the first read operation that attempts to read past the end of the file. It returns 0 if the current position is not end of file. There is no error return.


int FError(
    FILE * fFile)


If no error has occurred on fFile, this function returns 0. Otherwise, it returns a nonzero value.


int FFlush(
    FILE * fFile)


Returns 0 if the buffer was successfully flushed. The value 0 is also returned in cases in which the specified stream has no buffer or is open for reading only. A return value of EOF indicates an error.


int FGetC(
    FILE * fFile)


Returns the character read as an int or returns EOF to indicate an error or end of file.


char * FGetS(
    char * pcString,
    int iMax,
    FILE * fFile)


Reads a string from the input stream argument and stores it in pcString. This function reads characters from the current stream position to and including the first newline character, to the end of the stream, or until the number of characters read is equal to iMax 1, whichever comes first. The result stored in string is appended with a NULL character. The newline character, if read, is included in the string. NULL is returned to indicate an error.


int FGetWC(
    FILE * fFile)


Returns the wide character read as an int or returns WEOF to indicate an error or end of file.


wchar_t * FGetWS(
    wchar_t * pwString,
    int iMax,
    FILE * fFile)


Reads a string from the input stream argument and stores it in pwString. This function reads characters from the current stream position to and including the first newline character, to the end of the stream, or until the number of characters read is equal to iMax 1, whichever comes first. The result stored in string is appended with a NULL character. The newline character, if read, is included in the string. NULL is returned to indicate an error. Whether the characters are read as wide characters or multibyte characters depends on whether the stream was opened in text mode or binary mode, respectively.


FILE * FOpen(
    const char * pcFileName,
    const char * pcMode)


Returns a pointer to the opened file. A NULL pointer value indicates an error.

The character string pcMode specifies the type of access requested for the file, as follows:
    r: Opens for reading. If the file does not exist or cannot be found, the function fails.
    w: Opens an empty file for writing. If the given file exists, its contents are destroyed.
    a: Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesnt exist.
    r+: Opens for both reading and writing. (The file must exist.)
    w+: Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
    a+: Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesnt exist.


int FPrintF(
    FILE * fFile,
    const char * pcFormat,
    ...)


Formats and prints a series of characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in pcFormat. For this function, the pcFormat argument has the same syntax and use that it has in PrintF(). Returns the number of bytes written.


int FPutC(
    char cChar,
    FILE * fFile)


Writes character cChar to the stream. Returns the character written or EOF to indicate an error.


int FPutS(
    const char * pcString,
    FILE * fFile)


Copies pcString to the output stream at the current position, but does not copy the terminating NULL character. Returns EOF to indicate an error.


int FPutWC(
    wchar_t wChar,
    FILE * fFile)


Writes wide character wChar to the stream. Returns the wide character written or WEOF to indicate an error.


int FPutWS(
    const wchar_t * pwString,
    FILE * fFile)


Copies pwString to the output stream at the current position, but does not copy the terminating NULL character. Whether the characters are copied as wide characters or multibyte characters depends on whether the stream was opened in text mode or binary mode, respectively. Returns WEOF to indicate an error.


int FRead(
    void * pvBuffer,
    unsigned int uiSize,
    unsigned int uiCount,
    FILE * fFile)


Returns the number of full items actually read, which may be less than uiCount if an error occurs or if the end of the file is encountered before reaching uiCount. Use the FEof() or FError() function to distinguish a read error from an end-of-file condition. If size or count is 0, this function returns 0 and the buffer contents are unchanged.


int FScanF(
    FILE * fFile,
    const char * pcFormat,
    ...)


Reads data from the current position of stream into the locations given by the optional argument (...). Each argument must be a pointer to a variable of a type that corresponds to a type specifier in pcFormat. pcFormat controls the interpretation of the input fields and has the same form and function as the format argument for SScanF(); see SScanF() for a description of pcFormat. If copying takes place between strings that overlap, the behavior is undefined.


int FSeek(
    FILE * fFile,
    long lOffset,
    int iOrigin)


Moves the file pointer associated with stream to a new location that is lOffset bytes from iOrigin. The next operation on the stream takes place at the new location. The argument iOrigin must be one of the following constants:
    SEEK_CUR: Current position of file pointer.
    SEEK_END: End of file.
    SEEK_SET: Beginning of file.


int FTell(
    FILE * fFile)


Returns the current file position.


int FWPrintF(
    FILE * fFile,
    const wchar_t * pwFormat,
    ...)


Formats and prints a series of wide characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in pwFormat. For this function, the pwFormat argument has the same syntax and use that it has in PrintF(). Returns the number of wide characters written.


int FWScanF(
    FILE * fFile,
    const wchar_t * pwFormat,
    ...)


Reads data from the current position of stream into the locations given by the optional argument (...). Each argument must be a pointer to a variable of a type that corresponds to a type specifier in pwFormat. pwFormat controls the interpretation of the input fields and has the same form and function as the format argument for SWScanF(); see SWScanF() for a description of pwFormat. If copying takes place between strings that overlap, the behavior is undefined.


int FWrite(
    const void * pvBuffer,
    unsigned int uiSize,
    unsigned int uiCount,
    FILE * fFile)


Returns the number of full items actually written, which may be less than uiCount if an error occurs. Also, if an error occurs, the file-position indicator cannot be determined.


FILE * WFOpen(
    const wchar_t * pwFileName,
    const wchar_t * pwMode)


Returns a pointer to the opened file. A NULL pointer value indicates an error.

The character string pwMode specifies the type of access requested for the file, as follows:
    r: Opens for reading. If the file does not exist or cannot be found, the function fails.
    w: Opens an empty file for writing. If the given file exists, its contents are destroyed.
    a: Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesnt exist.
    r+: Opens for both reading and writing. (The file must exist.)
    w+: Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
    a+: Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesnt exist.


Copyright © 2006 Shawn (L. Spiro) Wilcoxen