You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Associates a stream with a file that was previously opened for low-level I/O.
16
16
@@ -29,81 +29,81 @@ FILE *_wfdopen(
29
29
30
30
### Parameters
31
31
32
-
*fd*<br/>
32
+
*`fd`*\
33
33
File descriptor of the open file.
34
34
35
-
*mode*<br/>
35
+
*`mode`*\
36
36
Type of file access.
37
37
38
-
## Return Value
38
+
## Return value
39
39
40
-
Each of these functions returns a pointer to the open stream. A null pointer value indicates an error. When an error occurs, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, **errno** is set either to **EBADF**, which indicates a bad file descriptor, or **EINVAL**, which indicates that *mode* was a null pointer.
40
+
Each of these functions returns a pointer to the open stream. A null pointer value indicates an error. When an error occurs, the invalid parameter handler is invoked, as described in [Parameter validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, `errno` is set either to `EBADF`, which indicates a bad file descriptor, or `EINVAL`, which indicates that *`mode`* was a null pointer.
41
41
42
-
For more information about these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
42
+
For more information about these and other error codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
43
43
44
44
## Remarks
45
45
46
-
The **_fdopen** function associates an I/O stream with the file that is identified by *fd*, and thus allows a file that is opened for low-level I/O to be buffered and formatted. **_wfdopen** is a wide-character version of **_fdopen**; the *mode* argument to **_wfdopen** is a wide-character string. **_wfdopen** and **_fdopen** otherwise behave identically.
46
+
The **`_fdopen`** function associates an I/O stream with the file that is identified by *`fd`*, and thus allows a file that is opened for low-level I/O to be buffered and formatted. **`_wfdopen`** is a wide-character version of **`_fdopen`**; the *mode* argument to **`_wfdopen`** is a wide-character string. **`_wfdopen`** and **`_fdopen`** otherwise behave identically.
47
47
48
-
File descriptors passed into **_fdopen** are owned by the returned `FILE *` stream. If **_fdopen** is successful, do not call [\_close](close.md) on the file descriptor. Calling [fclose](fclose-fcloseall.md) on the returned `FILE *` also closes the file descriptor.
48
+
File descriptors passed into **`_fdopen`** are owned by the returned `FILE *` stream. If **`_fdopen`** is successful, don't call [`_close`](close.md) on the file descriptor. Calling [`fclose`](fclose-fcloseall.md) on the returned `FILE *` also closes the file descriptor.
49
49
50
-
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
50
+
By default, this function's global state is scoped to the application. To change it, see [Global state in the CRT](../global-state.md).
51
51
52
-
### Generic-Text Routine Mappings
52
+
The *`mode`* character string specifies the type of file access requested for the file:
53
53
54
-
|Tchar.h routine|\_UNICODE and \_MBCS not defined|\_MBCS defined|\_UNICODE defined|
The *mode* character string specifies the type of file access requested for the file:
59
-
60
-
|*mode*| Access |
54
+
|*`mode`*| Access |
61
55
|--------|--------|
62
-
|**"r"**| Opens for reading. If the file does not exist or cannot be found, the **fopen** call fails. |
63
-
|**"w"**| Opens an empty file for writing. If the given file exists, its contents are destroyed. |
64
-
|**"a"**| Opens for writing at the end of the file (appending). Creates the file if it does not exist. |
65
-
|**"r+"**| Opens for both reading and writing. The file must exist. |
66
-
|**"w+"**| Opens an empty file for both reading and writing. If the file exists, its contents are destroyed. |
67
-
|**"a+"**| Opens for reading and appending. Creates the file if it does not exist. |
56
+
|**`"r"`**| Opens for reading. If the file doesn't exist or can't be found, the **`fopen`** call fails. |
57
+
|**`"w"`**| Opens an empty file for writing. If the given file exists, its contents are destroyed. |
58
+
|**`"a"`**| Opens for writing at the end of the file (appending). Creates the file if it doesn't exist. |
59
+
|**`"r+"`**| Opens for both reading and writing. The file must exist. |
60
+
|**`"w+"`**| Opens an empty file for both reading and writing. If the file exists, its contents are destroyed. |
61
+
|**`"a+"`**| Opens for reading and appending. Creates the file if it doesn't exist. |
68
62
69
-
When a file is opened with the **"a"** or **"a+"** access type, all write operations occur at the end of the file. The file pointer can be repositioned by using [fseek](fseek-fseeki64.md) or [rewind](rewind.md), but it is always moved back to the end of the file before any write operation is carried out. Thus, existing data cannot be overwritten. When the **"r+"**, **"w+"**, or **"a+"** access type is specified, both reading and writing are allowed (the file is said to be open for "update"). However, when you switch between reading and writing, there must be an intervening [fflush](fflush.md), [fsetpos](fsetpos.md), [fseek](fseek-fseeki64.md), or [rewind](rewind.md) operation. You can specify the current position for the [fsetpos](fsetpos.md) or [fseek](fseek-fseeki64.md) operation, if you want to.
63
+
When a file is opened with the **`"a"`** or **`"a+"`** access type, all write operations occur at the end of the file. The file pointer can be repositioned by using [`fseek`](fseek-fseeki64.md) or [`rewind`](rewind.md), but it's always moved back to the end of the file before any write operation is carried out. Thus, existing data can't be overwritten. When the **`"r+"`**, **`"w+"`**, or **`"a+"`** access type is specified, both reading and writing are allowed (the file is said to be open for "update"). However, when you switch between reading and writing, there must be an intervening [`fflush`](fflush.md), [`fsetpos`](fsetpos.md), [`fseek`](fseek-fseeki64.md), or [`rewind`](rewind.md) operation. You can specify the current position for the [`fsetpos`](fsetpos.md) or [`fseek`](fseek-fseeki64.md) operation, if you want to.
70
64
71
65
In addition to the above values, the following characters can also be included in *mode* to specify the translation mode for newline characters:
72
66
73
-
|*mode* modifier | Behavior |
67
+
|*`mode`* modifier | Behavior |
74
68
|-----------------|----------|
75
-
|**t**| Open in text (translated) mode. In this mode, carriage return-line feed (CR-LF) combinations are translated into one-line feeds (LF) on input, and LF characters are translated to CR-LF combinations on output. Also, Ctrl+Z is interpreted as an end-of-file character on input. |
76
-
|**b**| Open in binary (untranslated) mode. Any translations from **t** mode are suppressed. |
77
-
|**c**| Enable the commit flag for the associated *filename* so that the contents of the file buffer are written directly to disk if either **fflush** or **_flushall** is called. |
78
-
|**n**| Reset the commit flag for the associated *filename* to "no-commit." This is the default. It also overrides the global commit flag if you link your program with Commode.obj. The global commit flag default is "no-commit" unless you explicitly link your program with Commode.obj. |
79
-
80
-
The **t**, **c**, and **n***mode* options are Microsoft extensions for **fopen** and **_fdopen**. Do not use them if you want to preserve ANSI portability.
81
-
82
-
If **t** or **b**is not given in *mode*, the default translation mode is defined by the global variable [\_fmode](../../c-runtime-library/fmode.md). If **t** or **b** is prefixed to the argument, the function fails and returns NULL. For a discussion of text and binary modes, see [Text and Binary Mode File I/O](../../c-runtime-library/text-and-binary-mode-file-i-o.md).
83
-
84
-
Valid characters for the *mode* string used in **fopen** and **_fdopen** correspond to *oflag* arguments used in [\_open](open-wopen.md) and [\_sopen](sopen-wsopen.md), as shown in this table:
85
-
86
-
|Characters in *mode* string|Equivalent *oflag* value for **_open** and **_sopen**|
|**`t`**| Open in text (translated) mode. In this mode, carriage return-line feed (CR-LF) combinations are translated into one-line feeds (LF) on input, and LF characters are translated to CR-LF combinations on output. Also, Ctrl+Z is interpreted as an end-of-file character on input. |
70
+
|**`b`**| Open in binary (untranslated) mode. Any translations from **`t`** mode are suppressed. |
71
+
|**`c`**| Enable the commit flag for the associated *filename* so that the contents of the file buffer are written directly to disk if either **`fflush`** or **`_flushall`** is called. |
72
+
|**`n`**| Reset the commit flag for the associated *filename* to "no-commit." This flag is the default. It also overrides the global commit flag if you link your program with *`Commode.obj`*. The global commit flag default is "no-commit" unless you explicitly link your program with *`Commode.obj`*. |
73
+
74
+
The **`t`**, **`c`**, and **`n`***`mode`* options are Microsoft extensions for **`fopen`** and **`_fdopen`**. Don't use them if you want to preserve ANSI portability.
75
+
76
+
If **`t`** or **`b`**isn't given in *`mode`*, the default translation mode is defined by the global variable [`_fmode`](../../c-runtime-library/fmode.md). If **`t`** or **`b`** is prefixed to the argument, the function fails and returns `NULL`. For a discussion of text and binary modes, see [Text and binary mode file I/O](../../c-runtime-library/text-and-binary-mode-file-i-o.md).
77
+
78
+
Valid characters for the *`mode`* string used in **`fopen`** and **`_fdopen`** correspond to *`oflag`* arguments used in [`_open`](open-wopen.md) and [`_sopen`](sopen-wsopen.md), as shown in this table:
79
+
80
+
|Characters in *`mode`* string|Equivalent *`oflag`* value for **`_open`** and **`_sopen`**|
|**`_wfdopen`**|`<stdio.h>` or `<wchar.h>`|`<cstdio>`|
99
+
100
+
For more information on standards conformance and naming conventions in the C runtime library, see [Compatibility](../../c-runtime-library/compatibility.md).
101
+
102
+
### Generic-text routine mappings
105
103
106
-
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
104
+
|`<tchar.h>` routine |`_UNICODE` and `_MBCS` not defined |`_MBCS` defined |`_UNICODE` defined |
0 commit comments