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
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/freopen-wfreopen.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -78,9 +78,9 @@ When the **"r+"**, **"w+"**, or **"a+"** access type is specified, both reading
78
78
|*mode* modifier|Translation mode|
79
79
|-|-|
80
80
|**t**| Open in text (translated) mode. |
81
-
|**b**| Open in binary (untranslated) mode; translations involving carriage-return and linefeed characters are suppressed. |
81
+
|**b**| Open in binary (untranslated) mode; translations involving carriage-return and line feed characters are suppressed. |
82
82
83
-
In text (translated) mode, carriage return-linefeed (CR-LF) combinations are translated into single linefeed (LF) characters on input; LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading or for writing and reading with **"a+"**, the run-time library checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using [fseek](fseek-fseeki64.md) and [ftell](ftell-ftelli64.md) to move within a file may cause [fseek](fseek-fseeki64.md) to behave improperly near the end of the file. The **t** option is a Microsoft extension that should not be used where ANSI portability is desired.
83
+
In text (translated) mode, carriage return-line feed (CR-LF) combinations are translated into single line feed (LF) characters on input; LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading or for writing and reading with **"a+"**, the run-time library checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using [fseek](fseek-fseeki64.md) and [ftell](ftell-ftelli64.md) to move within a file may cause [fseek](fseek-fseeki64.md) to behave improperly near the end of the file. The **t** option is a Microsoft extension that should not be used where ANSI portability is desired.
84
84
85
85
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**.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/fseek-fseeki64.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ You can use **fseek** and **_fseeki64** to reposition the pointer anywhere in a
56
56
57
57
When a file is opened for appending data, the current file position is determined by the last I/O operation, not by where the next write would occur. If no I/O operation has yet occurred on a file opened for appending, the file position is the start of the file.
58
58
59
-
For streams opened in text mode, **fseek** and **_fseeki64** have limited use, because carriage return-linefeed translations can cause **fseek** and **_fseeki64** to produce unexpected results. The only **fseek** and **_fseeki64** operations guaranteed to work on streams opened in text mode are:
59
+
For streams opened in text mode, **fseek** and **_fseeki64** have limited use, because carriage return-line feed translations can cause **fseek** and **_fseeki64** to produce unexpected results. The only **fseek** and **_fseeki64** operations guaranteed to work on streams opened in text mode are:
60
60
61
61
- Seeking with an offset of 0 relative to any of the origin values.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/ftell-ftelli64.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Target **FILE** structure.
30
30
31
31
## Return Value
32
32
33
-
**ftell** and **_ftelli64** return the current file position. The value returned by **ftell** and **_ftelli64** may not reflect the physical byte offset for streams opened in text mode, because text mode causes carriage return-linefeed translation. Use **ftell** with [fseek](fseek-fseeki64.md) or **_ftelli64** with [_fseeki64](fseek-fseeki64.md) to return to file locations correctly. On error, **ftell** and **_ftelli64** invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1L and set **errno** to one of two constants, defined in ERRNO.H. The **EBADF** constant means the *stream* argument is not a valid file pointer value or does not refer to an open file. **EINVAL** means an invalid *stream* argument was passed to the function. On devices incapable of seeking (such as terminals and printers), or when *stream* does not refer to an open file, the return value is undefined.
33
+
**ftell** and **_ftelli64** return the current file position. The value returned by **ftell** and **_ftelli64** may not reflect the physical byte offset for streams opened in text mode, because text mode causes carriage return-line feed translation. Use **ftell** with [fseek](fseek-fseeki64.md) or **_ftelli64** with [_fseeki64](fseek-fseeki64.md) to return to file locations correctly. On error, **ftell** and **_ftelli64** invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1L and set **errno** to one of two constants, defined in ERRNO.H. The **EBADF** constant means the *stream* argument is not a valid file pointer value or does not refer to an open file. **EINVAL** means an invalid *stream* argument was passed to the function. On devices incapable of seeking (such as terminals and printers), or when *stream* does not refer to an open file, the return value is undefined.
34
34
35
35
See [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) for more information on these, and other, return codes.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/fwrite.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ Pointer to **FILE** structure.
43
43
44
44
## Remarks
45
45
46
-
The **fwrite** function writes up to *count* items, of *size* length each, from *buffer* to the output *stream*. The file pointer associated with *stream* (if there is one) is incremented by the number of bytes actually written. If *stream* is opened in text mode, each linefeed is replaced with a carriage-return - linefeed pair. The replacement has no effect on the return value.
46
+
The **fwrite** function writes up to *count* items, of *size* length each, from *buffer* to the output *stream*. The file pointer associated with *stream* (if there is one) is incremented by the number of bytes actually written. If *stream* is opened in text mode, each line feed is replaced with a carriage return-line feed pair. The replacement has no effect on the return value.
47
47
48
48
When *stream* is opened in Unicode translation mode—for example, if *stream* is opened by calling **fopen** and using a mode parameter that includes **ccs=UNICODE**, **ccs=UTF-16LE**, or **ccs=UTF-8**, or if the mode is changed to a Unicode translation mode by using **_setmode** and a mode parameter that includes **_O_WTEXT**, **_O_U16TEXT**, or **_O_U8TEXT**—*buffer* is interpreted as a pointer to an array of **wchar_t** that contains UTF-16 data. An attempt to write an odd number of bytes in this mode causes a parameter validation error.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/read.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Maximum number of bytes to read.
35
35
36
36
## Return Value
37
37
38
-
**_read** returns the number of bytes read, which might be less than *buffer_size* if there are fewer than *buffer_size* bytes left in the file, or if the file was opened in text mode. In text mode, each carriage return-line feed pair `\r\n` is replaced with a single linefeed character `\n`. Only the single linefeed character is counted in the return value. The replacement does not affect the file pointer.
38
+
**_read** returns the number of bytes read, which might be less than *buffer_size* if there are fewer than *buffer_size* bytes left in the file, or if the file was opened in text mode. In text mode, each carriage return-line feed pair `\r\n` is replaced with a single line feed character `\n`. Only the single line feed character is counted in the return value. The replacement does not affect the file pointer.
39
39
40
40
If the function tries to read at end of file, it returns 0. If *fd* is not valid, the file isn't open for reading, or the file is locked, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function returns -1 and sets **errno** to **EBADF**.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/write.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -35,19 +35,19 @@ Number of bytes.
35
35
36
36
## Return Value
37
37
38
-
If successful, **_write** returns the number of bytes actually written. If the actual space remaining on the disk is less than the size of the buffer the function is trying to write to the disk, **_write** fails and does not flush any of the buffer's contents to the disk. A return value of -1 indicates an error. If invalid parameters are passed, this function invokes the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function returns -1 and **errno** is set to one of three values: **EBADF**, which means the file descriptor is invalid or the file is not opened for writing; **ENOSPC**, which means there is not enough space left on the device for the operation; or **EINVAL**, which means that *buffer* was a null pointer or that an odd *count* of bytes was passed to be written to a file in Unicode mode.
38
+
If successful, **_write** returns the number of bytes written. If the actual space remaining on the disk is less than the size of the buffer the function is trying to write to the disk, **_write** fails and does not flush any of the buffer's contents to the disk. A return value of -1 indicates an error. If invalid parameters are passed, this function invokes the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function returns -1 and **errno** is set to one of three values: **EBADF**, which means the file descriptor is invalid or the file is not opened for writing; **ENOSPC**, which means there is not enough space left on the device for the operation; or **EINVAL**, which means that *buffer* was a null pointer or that an odd *count* of bytes was passed to be written to a file in Unicode mode.
39
39
40
40
For more information about these and other return codes, see [errno, _doserrno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
41
41
42
-
If the file is opened in text mode, each linefeed character is replaced with a carriage return - linefeed pair in the output. The replacement does not affect the return value.
42
+
If the file is opened in text mode, each line feed character is replaced with a carriage return-line feed pair in the output. The replacement doesn't affect the return value.
43
43
44
-
When the file is opened in Unicode translation mode—for example, if *fd* is opened by using **_open** or **_sopen** and a mode parameter that includes **_O_WTEXT**, **_O_U16TEXT**, or **_O_U8TEXT**, or if it is opened by using **fopen** and a mode parameter that includes **ccs=UNICODE**, **ccs=UTF-16LE**, or **ccs=UTF-8**, or if the mode is changed to a Unicode translation mode by using **_setmode**—*buffer* is interpreted as a pointer to an array of **wchar_t** that contains **UTF-16** data. An attempt to write an odd number of bytes in this mode causes a parameter validation error.
44
+
When the file is opened in Unicode translation mode—for example, if *fd* is opened by using **_open** or **_sopen** and a mode parameter that includes **_O_WTEXT**, **_O_U16TEXT**, or **_O_U8TEXT**, or if it's opened by using **fopen** and a mode parameter that includes **ccs=UNICODE**, **ccs=UTF-16LE**, or **ccs=UTF-8**, or if the mode is changed to a Unicode translation mode by using **_setmode**—*buffer* is interpreted as a pointer to an array of **wchar_t** that contains **UTF-16** data. An attempt to write an odd number of bytes in this mode causes a parameter validation error.
45
45
46
46
## Remarks
47
47
48
-
The **_write** function writes *count* bytes from *buffer* into the file associated with *fd*. The write operation begins at the current position of the file pointer (if any) associated with the given file. If the file is open for appending, the operation begins at the current end of the file. After the write operation, the file pointer is increased by the number of bytes actually written.
48
+
The **_write** function writes *count* bytes from *buffer* into the file associated with *fd*. The write operation begins at the current position of the file pointer (if any) associated with the given file. If the file is open for appending, the operation begins at the current end of the file. After the write operation, the file pointer is increased by the number of bytes written.
49
49
50
-
When writing to files opened in text mode, **_write** treats a CTRL+Z character as the logical end-of-file. When writing to a device, **_write** treats a CTRL+Z character in the buffer as an output terminator.
50
+
When writing to files opened in text mode, **_write** treats a CTRL+Z character as the logical end of file. When writing to a device, **_write** treats a CTRL+Z character in the buffer as an output terminator.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/translation-mode-constants.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ The allowed values are:
21
21
22
22
|||
23
23
|-|-|
24
-
`_O_TEXT` | Opens file in text (translated) mode. Carriage return - linefeed (CR-LF) combinations are translated into a single linefeed (LF) on input. Linefeed characters are translated into CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading and reading/writing, `fopen` checks for CTRL+Z at the end of the file and removes it, if possible. This is done because using the `fseek` and `ftell` functions to move within a file ending with CTRL+Z may cause `fseek` to behave improperly near the end of the file.
24
+
`_O_TEXT` | Opens file in text (translated) mode. Carriage return-line feed (CR-LF) combinations are translated into a single line feed (LF) on input. Line feed characters are translated into CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading, and for reading and writing, `fopen` checks for CTRL+Z at the end of the file and removes it, if possible. This is done because using the `fseek` and `ftell` functions to move within a file ending with CTRL+Z may cause `fseek` to behave improperly near the end of the file.
25
25
`_O_BINARY` | Opens file in binary (untranslated) mode. The above translations are suppressed.
26
26
`_O_RAW` | Same as `_O_BINARY`. Supported for C 2.0 compatibility.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/unicode-stream-i-o-in-text-and-binary-modes.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ When a Unicode stream I/O routine (such as **fwprintf**, **fwscanf**, **fgetwc**
11
11
12
12
- Unicode-to-MBCS or MBCS-to-Unicode conversion. When a Unicode stream-I/O function operates in text mode, the source or destination stream is assumed to be a sequence of multibyte characters. Therefore, the Unicode stream-input functions convert multibyte characters to wide characters (as if by a call to the **mbtowc** function). For the same reason, the Unicode stream-output functions convert wide characters to multibyte characters (as if by a call to the **wctomb** function).
13
13
14
-
- Carriage return - linefeed (CR-LF) translation. This translation occurs before the MBCS - Unicode conversion (for Unicode stream input functions) and after the Unicode - MBCS conversion (for Unicode stream output functions). During input, each carriage return - linefeed combination is translated into a single linefeed character. During output, each linefeed character is translated into a carriage return - linefeed combination.
14
+
- Carriage return-line feed (CR-LF) translation. This translation occurs before the MBCS - Unicode conversion (for Unicode stream input functions) and after the Unicode - MBCS conversion (for Unicode stream output functions). During input, each carriage return-line feed combination is translated into a single line feed character. During output, each line feed character is translated into a carriage return-line feed combination.
15
15
16
-
However, when a Unicode stream-I/O function operates in binary mode, the file is assumed to be Unicode, and no CR-LF translation or character conversion occurs during input or output. Use the _setmode( _fileno( stdin ), _O_BINARY ); instruction in order to correctly use wcin on a UNICODE text file.
16
+
However, when a Unicode stream-I/O function operates in binary mode, the file is assumed to be Unicode, and no CR-LF translation or character conversion occurs during input or output. Use the `_setmode( _fileno( stdin ), _O_BINARY );` instruction in order to correctly use `wcin` on a UNICODE text file.
0 commit comments