![]() |
![]() |
![]() |
![]() |
![]() |
|
Just as ifstream creates a stream that enables you to read
from a file, ofstream, an acronym for output
file stream, creates a stream that enables you to
write into a file:
ofstream stream name (file specification);
The following file-opening statement is an example for which the stream name happens to
be volume_stream and the file specification happens to
be provided by the character string "test.result":
ofstream volume_stream ("test.result");
In general, ofstream statements include a stream
name, volume_stream in the example. Then, surrounded by
parentheses, comes a file specification, such as
"test.result".