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
Represents a C run-time stream file as opened by the run-time function [fopen](../../c-runtime-library/reference/fopen-wfopen.md).
11
+
Represents a C run-time stream file as opened by the run-time function [`fopen`](../../c-runtime-library/reference/fopen-wfopen.md).
12
12
13
13
## Syntax
14
14
@@ -22,48 +22,48 @@ class CStdioFile : public CFile
22
22
23
23
|Name|Description|
24
24
|----------|-----------------|
25
-
|[CStdioFile::CStdioFile](#cstdiofile)|Constructs a `CStdioFile` object from a path or file pointer.|
25
+
|[`CStdioFile::CStdioFile`](#cstdiofile)|Constructs a `CStdioFile` object from a path or file pointer.|
26
26
27
27
### Public Methods
28
28
29
29
|Name|Description|
30
30
|----------|-----------------|
31
-
|[CStdioFile::Open](#open)|Overloaded. Open is designed for use with the default `CStdioFile` constructor (Overrides [CFile::Open](../../mfc/reference/cfile-class.md#open)).|
32
-
|[CStdioFile::ReadString](#readstring)|Reads a single line of text.|
33
-
|[CStdioFile::Seek](#seek)|Positions the current file pointer.|
34
-
|[CStdioFile::WriteString](#writestring)|Writes a single line of text.|
31
+
|[`CStdioFile::Open`](#open)|Overloaded. Open is designed for use with the default `CStdioFile` constructor (Overrides [`CFile::Open`](../../mfc/reference/cfile-class.md#open)).|
32
+
|[`CStdioFile::ReadString`](#readstring)|Reads a single line of text.|
33
+
|[`CStdioFile::Seek`](#seek)|Positions the current file pointer.|
34
+
|[`CStdioFile::WriteString`](#writestring)|Writes a single line of text.|
35
35
36
36
### Public Data Members
37
37
38
38
|Name|Description|
39
39
|----------|-----------------|
40
-
|[CStdioFile::m_pStream](#m_pstream)|Contains a pointer to an open file.|
40
+
|[`CStdioFile::m_pStream`](#m_pstream)|Contains a pointer to an open file.|
41
41
42
42
## Remarks
43
43
44
44
Stream files are buffered and can be opened in either text mode (the default) or binary mode.
45
45
46
46
Text mode provides special processing for carriage return-line feed pairs. When you write a line feed (newline) character (0x0A) to a text-mode `CStdioFile` object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0D, 0x0A) is translated to a single 0x0A byte.
47
47
48
-
The [CFile](../../mfc/reference/cfile-class.md) functions [Duplicate](../../mfc/reference/cfile-class.md#duplicate), [LockRange](../../mfc/reference/cfile-class.md#lockrange), and [UnlockRange](../../mfc/reference/cfile-class.md#unlockrange) are not supported for `CStdioFile`.
48
+
The [`CFile`](../../mfc/reference/cfile-class.md) functions [`Duplicate`](../../mfc/reference/cfile-class.md#duplicate), [`LockRange`](../../mfc/reference/cfile-class.md#lockrange), and [`UnlockRange`](../../mfc/reference/cfile-class.md#unlockrange) are not supported for `CStdioFile`.
49
49
50
-
If you call these functions on a `CStdioFile`, you will get a [CNotSupportedException](../../mfc/reference/cnotsupportedexception-class.md).
50
+
If you call these functions on a `CStdioFile`, you will get a [`CNotSupportedException`](../../mfc/reference/cnotsupportedexception-class.md).
51
51
52
52
For more information on using `CStdioFile`, see the articles [Files in MFC](../../mfc/files-in-mfc.md) and [File Handling](../../c-runtime-library/file-handling.md) in the *Run-Time Library Reference*.
Specifies the file pointer returned by a call to the C run-time function [fopen](../../c-runtime-library/reference/fopen-wfopen.md).
87
+
*`pOpenStream`*<br/>
88
+
Specifies the file pointer returned by a call to the C run-time function [`fopen`](../../c-runtime-library/reference/fopen-wfopen.md).
89
89
90
-
*lpszFileName*<br/>
90
+
*`lpszFileName`*<br/>
91
91
Specifies a string that is the path to the desired file. The path can be relative or absolute.
92
92
93
-
*nOpenFlags*<br/>
94
-
Specifies options for file creation, file sharing, and file access modes. You can specify multiple options by using the bitwise OR ( **|** ) operator.
93
+
*`nOpenFlags`*<br/>
94
+
Specifies options for file creation, file sharing, and file access modes. You can specify multiple options by using the bitwise OR ( **`|`** ) operator.
95
95
96
-
One file access mode option is required; other modes are optional. See [CFile::CFile](../../mfc/reference/cfile-class.md#cfile) for a list of mode options and other flags. In MFC version 3.0 and later, share flags are allowed.
96
+
One file access mode option is required; other modes are optional. See [`CFile::CFile`](../../mfc/reference/cfile-class.md#cfile) for a list of mode options and other flags. In MFC version 3.0 and later, share flags are allowed.
97
97
98
-
*pTM*<br/>
99
-
Pointer to CAtlTransactionManager object.
98
+
*`pTM`*<br/>
99
+
Pointer to `CAtlTransactionManager` object.
100
100
101
101
### Remarks
102
102
103
103
The default constructor does not attach a file to the `CStdioFile` object. When using this constructor, you must use the `CStdioFile::Open` method to open a file and attach it to the `CStdioFile` object.
104
104
105
-
The single-parameter constructor attaches an open file stream to the `CStdioFile` object. Allowed pointer values include the predefined input/output file pointers *stdin*, *stdout*, or *stderr*.
105
+
The single-parameter constructor attaches an open file stream to the `CStdioFile` object. Allowed pointer values include the predefined input/output file pointers *`stdin`*, *`stdout`*, or *`stderr`*.
106
106
107
107
The two-parameter constructor creates a `CStdioFile` object and opens the corresponding file with the given path.
108
108
109
-
If you pass NULL for either *pOpenStream* or *lpszFileName*, the constructor throws a `CInvalidArgException*`.
109
+
If you pass `NULL` for either *`pOpenStream`* or *`lpszFileName`*, the constructor throws a `CInvalidArgException*`.
110
110
111
111
If the file cannot be opened or created, the constructor throws a `CFileException*`.
The `m_pStream` data member is the pointer to an open file as returned by the C run-time function `fopen`.
120
120
@@ -124,9 +124,9 @@ FILE* m_pStream;
124
124
125
125
### Remarks
126
126
127
-
It is NULL if the file has never been opened or has been closed.
127
+
It is `NULL` if the file has never been opened or has been closed.
128
128
129
-
## <aname="open"></a> CStdioFile::Open
129
+
## <aname="open"></a> `CStdioFile::Open`
130
130
131
131
Overloaded. Open is designed for use with the default `CStdioFile` constructor.
132
132
@@ -145,27 +145,27 @@ virtual BOOL Open(
145
145
146
146
### Parameters
147
147
148
-
*lpszFileName*<br/>
148
+
*`lpszFileName`*<br/>
149
149
A string that is the path to the desired file. The path can be relative or absolute.
150
150
151
-
*nOpenFlags*<br/>
151
+
*`nOpenFlags`*<br/>
152
152
Sharing and access mode. Specifies the action to take when opening the file. You can combine options by using the bitwise-OR (|) operator. One access permission and one share option are required; the modeCreate and modeNoInherit modes are optional.
153
153
154
-
*pError*<br/>
154
+
*`pError`*<br/>
155
155
A pointer to an existing file-exception object that will receive the status of a failed operation.
Specifies a pointer to a user-supplied buffer that will receive a null-terminated text string.
182
182
183
-
*nMax*<br/>
183
+
*`nMax`*<br/>
184
184
Specifies the maximum number of characters to read, not counting the terminating null character.
185
185
186
-
*rString*<br/>
186
+
*`rString`*<br/>
187
187
A reference to a `CString` object that will contain the string when the function returns.
188
188
189
189
### Return Value
190
190
191
-
A pointer to the buffer containing the text data. NULL if end-of-file was reached without reading any data; or if boolean, FALSE if end-of-file was reached without reading any data.
191
+
A pointer to the buffer containing the text data. `NULL` if end-of-file was reached without reading any data; or if boolean, `FALSE` if end-of-file was reached without reading any data.
192
192
193
193
### Remarks
194
194
195
-
Reading is stopped by the first newline character. If, in that case, fewer than *nMax*-1 characters have been read, a newline character is stored in the buffer. A null character ('\0') is appended in either case.
195
+
Reading is stopped by the first newline character. If, in that case, fewer than *`nMax`*-1 characters have been read, a newline character is stored in the buffer. A null character (`'\0'`) is appended in either case.
196
196
197
-
[CFile::Read](../../mfc/reference/cfile-class.md#read) is also available for text-mode input, but it does not terminate on a carriage return-line feed pair.
197
+
[`CFile::Read`](../../mfc/reference/cfile-class.md#read) is also available for text-mode input, but it does not terminate on a carriage return-line feed pair.
198
198
199
199
> [!NOTE]
200
-
> The `CString` version of this function removes the `'\n'` if present; the LPTSTR version does not.
200
+
> The `CString` version of this function removes the `'\n'` if present; the `LPTSTR` version does not.
Repositions the pointer in a previously opened file.
209
209
@@ -215,17 +215,17 @@ virtual ULONGLONG Seek(
215
215
216
216
### Parameters
217
217
218
-
*lOff*<br/>
218
+
*`lOff`*<br/>
219
219
Number of bytes to move the pointer.
220
220
221
-
*nFrom*<br/>
221
+
*`nFrom`*<br/>
222
222
Pointer movement mode. Must be one of the following values:
223
223
224
-
-`CFile::begin`: Move the file pointer *lOff* bytes forward from the beginning of the file.
224
+
-`CFile::begin`: Move the file pointer *`lOff`* bytes forward from the beginning of the file.
225
225
226
-
-`CFile::current`: Move the file pointer *lOff* bytes from the current position in the file.
226
+
-`CFile::current`: Move the file pointer *`lOff`* bytes from the current position in the file.
227
227
228
-
-`CFile::end`: Move the file pointer *lOff* bytes from the end of the file. Note that *lOff* must be negative to seek into the existing file; positive values will seek past the end of the file.
228
+
-`CFile::end`: Move the file pointer *`lOff`* bytes from the end of the file. Note that *`lOff`* must be negative to seek into the existing file; positive values will seek past the end of the file.
229
229
230
230
### Return Value
231
231
@@ -237,15 +237,15 @@ The `Seek` function permits random access to a file's contents by moving the poi
237
237
238
238
When a file is opened, the file pointer is positioned at offset 0, the beginning of the file.
239
239
240
-
This implementation of `Seek` is based on the Run-Time Library (CRT) function `fseek`. There are several limits on the usage of `Seek` on streams opened in text mode. For more information, see [fseek, _fseeki64](../../c-runtime-library/reference/fseek-fseeki64.md).
240
+
This implementation of `Seek` is based on the Run-Time Library (CRT) function `fseek`. There are several limits on the usage of `Seek` on streams opened in text mode. For more information, see [`fseek`, `_fseeki64`](../../c-runtime-library/reference/fseek-fseeki64.md).
241
241
242
242
### Example
243
243
244
-
The following example shows how to use `Seek` to move the pointer 1000 bytes from the beginning of the `cfile` file. Note that `Seek` does not read data, so you must subsequently call [CStdioFile::ReadString](#readstring) to read data.
244
+
The following example shows how to use `Seek` to move the pointer 1000 bytes from the beginning of the `cfile` file. Note that `Seek` does not read data, so you must subsequently call [`CStdioFile::ReadString`](#readstring) to read data.
Specifies a pointer to a buffer that contains a null-terminated string.
260
260
261
261
### Remarks
262
262
263
-
The terminating null character ( `\0`) is not written to the file. This method writes newline characters in *lpsz* to the file as a carriage return-line feed pair.
263
+
The terminating null character ( `\0`) is not written to the file. This method writes newline characters in *`lpsz`* to the file as a carriage return-line feed pair.
264
264
265
-
If you want to write data that is not null-terminated to a file, use `CStdioFile::Write` or [CFile::Write](../../mfc/reference/cfile-class.md#write).
265
+
If you want to write data that is not null-terminated to a file, use `CStdioFile::Write` or [`CFile::Write`](../../mfc/reference/cfile-class.md#write).
266
266
267
-
This method throws a `CInvalidArgException*` if you specify NULL for the *lpsz* parameter.
267
+
This method throws a `CInvalidArgException*` if you specify `NULL` for the *`lpsz`* parameter.
268
268
269
269
This method throws a `CFileException*` in response to file system errors.
270
270
@@ -274,10 +274,10 @@ This method throws a `CFileException*` in response to file system errors.
0 commit comments