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
* draft
* fix code sample (#3676)
* fix code sample
* acrolinx
Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com>
* document clocks
* add tai-clock
* Address 3269 typo in warning number (#3680)
* Fixed typo: evalution --> evaluation
* updates
* finish draft of new clocks
* acrolinx
* Fixed typo: evalution --> evaluation
* Bulk Fix - Sentence form for all alt text (#3683)
* Updated C/C++ workload name
The workload for C/C++ development in VS Build Tools 2019 installer is called 'Desktop development with C++'.
* Split out docs by version
Add VS2017-specific instructions.
* Updated C/C++ workload name
The workload for C/C++ development in VS Build Tools 2019 installer is called 'Desktop development with C++'.
* Split out docs by version
Add VS2017-specific instructions.
* Add 16.11 Compiler Warnings C5247 and C5248 (MicrosoftDocs#3689)
* Add C5247 and C5248
* Fix link typos
* Updates per Xiang Fan review
* More wordsmithage
* More fix per X.F.
* Fix inconsistencies in CMake docs (MicrosoftDocs#3692)
* Standard format for CMake docs
* Fix markdownlint
* More cleanup.
* Clean up link issue, acrolinx
* Fix more broken things
* Undo a change
* Add documentation for "unspecified" architecture
Add documentation regarding "unspecified" architecture such that it provides an option for someone to ensure that no inherited environment is selected.
* Update markdownlint.json file for unordered lists (#3694)
Block rule that wants * instead of - to prefix unordered lists, since we've standardized on the latter.
Merging on my own recognizance as repo admin.
* Clean up documentation for "unspecified" architecture
* Markdown quality fixes 1 of N
* Markdown quality fixes 2 of N
* Markdown quality fixes 3 of N
* Markdown quality fixes 4 of N
* Markdown quality fixes 5 of N
* Markdown quality fixes 6 of N
* Markdown quality fixes 7 of N
* Markdown quality fixes 8 of N
* Markdown quality fixes 9 of N
* Markdown quality fixes 10 of N
* Undo TN038
* Markdown quality fixes 11 of N
* Setting PATH allows DUMPBIN to be executed from the system command prompt.
There are multiple DUMPBIN.EXE's in the MSVC folder, but they can be executed if the PATH is set correctly.
If this is not true, or undesireable per system design constraints, please clarify otherwise.
* Call out toolchains and embedded scenarios
* Add link to environment setting instructions
* Make more readable
* Address cpp-docs 3286 Postfix increment, decrement syntax (MicrosoftDocs#3711)
* Address cpp-docs issue 3286
* Fix formatting, final example
* Add compiler warning C5243, C5249, C5250 (MicrosoftDocs#3710)
* Removing linux and non-windows bullet point
* Make clear it's not required to meet all conditions
Add "or" to final bullet point
* PR review edit, Microsoft style for lists
* Make the "unspecified" architecture option more general
* Add __SANITIZE_ADDRESS__ to predefined macros page
Noticed __SANITIZE_ADDRESS__ was missing from this list.
* Add VS version
Also note the VS version where __SANITIZE_ADDRESS__ was added in.
* Add docs on using existing cache without cmake-server
* Fix unescaped <chrono> (MicrosoftDocs#3715)
Noticed this while doing other changes. Without being in a code block, <chrono> becomes the html element of the same name.
* Address issue 3301
* Create and integrate /Zc:lambda article (#3719)
* Create and integrate /Zc:lambda article
* Fix conformance topic date
* First half of C++20 changes
* The other half of the /std:c++20 fixes
* Fix link
* Update cmake-projects-in-visual-studio.md
* Remove duplicate line in build TOC
* tech review
* fixes
* Cleanup per review
* Update thread-class.md
* Update future-functions.md
* Update execution.md
* Update execution.md
* Update execution.md
* Update future-functions.md
* Update thread-class.md
* Update execution.md
* Update future-functions.md
* Update thread-class.md
* updates per tech review and other
* added file_clock
* Update execution.md
* Update future-functions.md
* Update thread-class.md
* add gps_clock
* update metadata
* PR review edit, relative links
* PR review edit, relative links
* PR review edit, relative link
* Fixed typo in bit-functions.md
* Further typo fix
* finished draft for local_t
* acrolinx
* Fixed broken links
* incorp tech review
* update typedef sections
* add all related typedefs
* fix tables
* acrolinx
* cleanup
* fix links
* fix tables
* more table cleanup
* another fix for tables. error msgs aren't by the error but I think I finally found the issue
* one more table fix
* typos
* typo in code example
* Update links to ARM docs (#3735)
* Update links to ARM docs
* Acrolinx and formatting pass
* Acrolinx
* Fix locale_t -> _locale_t
* Update output-file-stream-member-functions.md
Updated some code escapes for localization
* Address github issues (MicrosoftDocs#3737)
* fix github 3268 code example for Context::Yield()
* fixed github #3312 - MFC CWnd::OnMouseHWheel description
* Fix for github #3259-clarify change in the UI
* acrolinx
Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com>
* Update how-to-convert-standard-string-to-system-string.md
Fixing example.
-------
cc: @TylerMSFT
GitHub Issue: https://github.com/MicrosoftDocs/cpp-docs/issues/2438
* PR review edit, date
* Typo: B::f instead of B::F
Co-authored-by: Colin Robertson <corob@microsoft.com>
Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com>
Co-authored-by: opbld15 <opbld15@microsoft.com>
Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com>
Co-authored-by: opbld17 <opbld17@microsoft.com>
Co-authored-by: ystamant <49958001+ystamant@users.noreply.github.com>
Co-authored-by: opbld16 <opbld16@microsoft.com>
Co-authored-by: Andrew Shymanel <88244804+ainrd@users.noreply.github.com>
Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com>
Co-authored-by: PRMerger6 <prmrgr6@microsoft.com>
Co-authored-by: PRMerger12 <prmrgr12@microsoft.com>
Co-authored-by: PRMerger14 <prmrgr14@microsoft.com>
Co-authored-by: PRMerger16 <prmrgr16@microsoft.com>
Co-authored-by: PRMerger15 <prmrgr15@microsoft.com>
Co-authored-by: PRMerger7 <prmrgr7@microsoft.com>
Co-authored-by: PRMerger10 <prmrgr10@microsoft.com>
Co-authored-by: David Dyck <david.dyck@gmail.com>
Co-authored-by: Kristine Toliver <ktoliver@users.noreply.github.com>
Co-authored-by: Steve Wishnousky <stwish@microsoft.com>
Co-authored-by: Sam Freed <sfreed141@gmail.com>
Co-authored-by: Don Spencer <87099566+v-donspencer@users.noreply.github.com>
Co-authored-by: Beau Braig <86677107+BeauBraig@users.noreply.github.com>
Co-authored-by: Alex Guteniev <gutenev@gmail.com>
Co-authored-by: Paula Miller <v-paulmi@microsoft.com>
Co-authored-by: RibShark <1957489+RibShark@users.noreply.github.com>
Co-authored-by: onihusube <44743040+onihusube@users.noreply.github.com>
Co-authored-by: PRMerger8 <prmrgr8@microsoft.com>
Co-authored-by: Chris Ho <sudoerchris.ho@pm.me>
Co-authored-by: Andrew Rogers <andrew.rogers@wdc.com>
Co-authored-by: Sauparna Palchowdhury <91951+sauparna@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/standard-library/output-file-stream-member-functions.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,25 @@
1
1
---
2
2
description: "Learn more about: Output File Stream Member Functions"
3
3
title: "Output File Stream Member Functions"
4
-
ms.date: "11/04/2016"
4
+
ms.date: "08/25/2021"
5
5
helpviewer_keywords: ["output streams [C++], member functions"]
6
-
ms.assetid: 38aaf710-8035-4a34-a0c4-123a5327f28a
7
6
---
8
7
# Output File Stream Member Functions
9
8
10
9
Output stream member functions have three types: those that are equivalent to manipulators, those that perform unformatted write operations, and those that otherwise modify the stream state and have no equivalent manipulator or insertion operator. For sequential, formatted output, you might use only insertion operators and manipulators. For random-access binary disk output, you use other member functions, with or without insertion operators.
11
10
12
11
## The open Function for Output Streams
13
12
14
-
To use an output file stream ([ofstream](../standard-library/basic-ofstream-class.md)), you must associate that stream with a specific disk file in the constructor or the `open` function. If you use the `open` function, you can reuse the same stream object with a series of files. In either case, the arguments describing the file are the same.
13
+
To use an output file stream ([`ofstream`](../standard-library/basic-ofstream-class.md)), you must associate that stream with a specific disk file in the constructor or the `open` function. If you use the `open` function, you can reuse the same stream object with a series of files. In either case, the arguments describing the file are the same.
15
14
16
-
When you open the file associated with an output stream, you generally specify an `open_mode` flag. You can combine these flags, which are defined as enumerators in the `ios` class, with the bitwise OR ( | ) operator. See [ios_base::openmode](../standard-library/ios-base-class.md#openmode) for a list of the enumerators.
15
+
When you open the file associated with an output stream, you generally specify an `open_mode` flag. You can combine these flags, which are defined as enumerators in the `ios` class, with the bitwise OR ( `|` ) operator. See [`ios_base::openmode`](../standard-library/ios-base-class.md#openmode) for a list of the enumerators.
17
16
18
17
Three common output stream situations involve mode options:
19
18
20
19
- Creating a file. If the file already exists, the old version is deleted.
21
20
22
21
```cpp
23
-
ostreamofile("FILENAME");
22
+
ofstreamofile("FILENAME");
24
23
// Default is ios::out
25
24
26
25
ofstream ofile("FILENAME", ios::out);
@@ -46,9 +45,9 @@ Three common output stream situations involve mode options:
46
45
// When ofile goes out of scope it is destroyed.
47
46
```
48
47
49
-
## The put
48
+
## The `put` function
50
49
51
-
The **put** function writes one character to the output stream. The following two statements are the same by default, but the second is affected by the stream's format arguments:
50
+
The `put` function writes one character to the output stream. The following two statements are the same by default, but the second is affected by the stream's format arguments:
52
51
53
52
```cpp
54
53
cout.put('A');
@@ -57,7 +56,7 @@ cout.put('A');
57
56
cout <<'A'; // Format arguments 'width' and 'fill' apply
58
57
```
59
58
60
-
## The write
59
+
## The `write` function
61
60
62
61
The `write` function writes a block of memory to an output file stream. The length argument specifies the number of bytes written. This example creates an output file stream and writes the binary value of the `Date` structure to it:
63
62
@@ -80,7 +79,7 @@ int main( )
80
79
}
81
80
```
82
81
83
-
The `write` function does not stop when it reaches a null character, so the complete class structure is written. The function takes two arguments: a **`char`** pointer and a count of characters to write. Note the required cast to **`char`**<strong>\*</strong> before the address of the structure object.
82
+
The `write` function does not stop when it reaches a null character, so the complete class structure is written. The function takes two arguments: a **`char`** pointer and a count of characters to write. Note the required cast to **`char *`** before the address of the structure object.
84
83
85
84
## The seekp and tellp Functions
86
85
@@ -98,12 +97,12 @@ Use these member functions to test for errors while writing to a stream:
98
97
99
98
|Function|Return value|
100
99
|--------------|------------------|
101
-
|[bad](basic-ios-class.md#bad)|Returns **`true`** if there is an unrecoverable error.|
102
-
|[fail](basic-ios-class.md#fail)|Returns **`true`** if there is an unrecoverable error or an "expected" condition, such as a conversion error, or if the file is not found. Processing can often resume after a call to `clear` with a zero argument.|
103
-
|[good](basic-ios-class.md#good)|Returns **`true`** if there is no error condition (unrecoverable or otherwise) and the end-of-file flag is not set.|
104
-
|[eof](basic-ios-class.md#eof)|Returns **`true`** on the end-of-file condition.|
105
-
|[clear](basic-ios-class.md#clear)|Sets the internal error state. If called with the default arguments, it clears all error bits.|
106
-
|[rdstate](basic-ios-class.md#rdstate|Returns the current error state.|
100
+
|[`bad`](basic-ios-class.md#bad)|Returns **`true`** if there is an unrecoverable error.|
101
+
|[`fail`](basic-ios-class.md#fail)|Returns **`true`** if there is an unrecoverable error or an "expected" condition, such as a conversion error, or if the file is not found. Processing can often resume after a call to `clear` with a zero argument.|
102
+
|[`good`](basic-ios-class.md#good)|Returns **`true`** if there is no error condition (unrecoverable or otherwise) and the end-of-file flag is not set.|
103
+
|[`eof`](basic-ios-class.md#eof)|Returns **`true`** on the end-of-file condition.|
104
+
|[`clear`](basic-ios-class.md#clear)|Sets the internal error state. If called with the default arguments, it clears all error bits.|
105
+
|[`rdstate`](basic-ios-class.md#rdstate|Returns the current error state.|
107
106
108
107
The **!** operator is overloaded to perform the same function as the `fail` function. Thus the expression:
109
108
@@ -117,7 +116,7 @@ is equivalent to:
117
116
if(cout.fail())...
118
117
```
119
118
120
-
The **void\*()** operator is overloaded to be the opposite of the **!** operator; thus the expression:
119
+
The **`void*()`** operator is overloaded to be the opposite of the **`!`** operator; thus the expression:
121
120
122
121
```cpp
123
122
if(cout)...
@@ -129,7 +128,7 @@ is equal to:
129
128
if(!cout.fail())...
130
129
```
131
130
132
-
The **void\*()** operator is not equivalent to `good` because it does not test for the end of file.
131
+
The **`void*()`** operator is not equivalent to `good` because it does not test for the end of file.
0 commit comments