| CMPSC 101 - Files Worksheet #1 | Name - |
1. (True/False) A sequential access file can be opened in the append mode so
that data can automatically be written to the end of the file.
2. (True/False) The identifier infile would
be a good choice for a file pointer that points to a file that you wish to read
data from.
3. (True/False) The statement outfile
<< "hello world" << endl; contains
a syntax error.
4. Write a statement that declares a file pointer named infile that is to be
used to obtain input from a file.
5. Write a statement that declares a file pointer named outfile that is to
be used to write data to a file opened for output.
6. Write a statement that opens a sequential access file named HighScores.txt
for output. You can assume that the file is located in the same folder as the
C++ source file.
7. Write a statement that writes the value of the integer variable named score to
the file pointed to by the file pointer named outfile.
8. Write a statement that writes the string literal "hello world"
to the file pointed to by the file pointer named outfile.
9. Write a statement that closes a sequential access file pointed to by the file pointer named outfile.