To create an input stream, you use a file-opening statement that sets up an input stream, names the stream, and specifies the file:
ifstream stream name (file specification);
The following is an example in which the stream happens to be named
cylinder_stream
and the file specification happens to be
"test.data"
:
ifstream cylinder_stream ("test.data");
Thus, input file-opening statements include
ifstream
, an acronym for
input file stream, followed by a stream name such
as cylinder_stream
. Then, surrounded by parentheses, comes a file
specification, such as "test.data"
.
Of course, the file specification may include a file directory path, as in the following example:
ifstream cylinder_stream ("/usr/phw/cpp/test.data");