| Parameter | Details |
|---|---|
| const char *mode | A string describing the opening mode of the file-backed stream. See remarks for possible values. |
| int whence | Can be SEEK_SET to set from the beginning of the file, SEEK_END to set from its end, or SEEK_CUR to set relative to the current cursor value. Note: SEEK_END is non-portable. |
Mode strings in fopen() and freopen() can be one of those values:
"r": Open the file in read-only mode, with the cursor set to the beginning of the file."r+": Open the file in read-write mode, with the cursor set to the beginning of the file."w": Open or create the file in write-only mode, with its content truncated to 0 bytes. The cursor is set to the beginning of the file."w+": Open or create the file in read-write mode, with its content truncated to 0 bytes. The cursor is set to the beginning of the file."a": Open or create the file in write-only mode, with the cursor set to the end of the file."a+": Open or create the file in read-write mode, with the read-cursor set to the beginning of the file. The output, however, will always be appended to the end of the file.Each of these file modes may have a b added after the initial letter (e.g. "rb" or "a+b" or "ab+"). The b means that the file should be treated as a binary file instead of a text file on those systems where there is a difference. It doesn't make a difference on Unix-like systems; it is important on Windows systems. (Additionally, Windows fopen allows an explicit t instead of b to indicate 'text file' — and numerous other platform-specific options.)
"wx": Create a text file in write-only mode. The file may not exist."wbx": Create a binary file in write-only mode. The file may not exist.The x, if present, must be the last character in the mode string.