1. n this week’s lab, you will be writing a program to maintain a simple contact list in a file. To

1.

n this week’s lab, you will be writing a program to maintain a simple contact list in a file. To do this, you’ll want to be able to both read from and write to the same file. Continuing to use the classes provided when you use:

#include <fstream>

What class should your file object be to allow it to both read from and write to the file? You may have to do some searching using Google, or some other search engine, to find an answer to this and the other questions in this pre-lab.

2.

If the file doesn’t yet exist, an attempt to open it in the same way with this class as we’ve been opening files will fail. How do you open the file so that it is created when you open it for both reading and writing? You’ll want to write a program to test this technique to make sure you’ve understood it correctly.

3.

Using the program you constructed to test creating a file, test it’s behavior on a file that already exists. What happens to an existing file that is opened in the manner of Step 2? Write a few lines of code that properly creates a file if it doesn’t exist, but opens it without affecting it, if it does exist.

4.

Write a statement that will move your position to the beginning of the file so that you can begin to read it all the way through.

Write a statement that will move your position to the end of the file so that writes will be placed after the current contents of the file.

NEED HELP WITH SUCH A TASK? WE HAVE THE BEST TUTORS FOR YOU. ORDER NOW FROM 10$/PG