Chapter 12: Problem 46
Write code that opens the file data.txt for both input and output, but first determines if the file exists. If the file does not exist, the code should create it, then open it for both input and output.
Chapter 12: Problem 46
Write code that opens the file data.txt for both input and output, but first determines if the file exists. If the file does not exist, the code should create it, then open it for both input and output.
All the tools & learning materials you need for study success - in one app.
Get started for freeT F ofstream objects, by default, delete the contents of a file if it already exists when opened.
T F The getline member function can be used to read text that contains whitespaces.
Write two statements that use a file stream object named pets to open a file named pets.dat. (Show how to open the file with a member function and at the definition of the file stream object.) The file should be opened for input.
T F A file stream object’s fail member function may be used to determine if the file was successfully opened.
What capability does the fstream data type provide that the ifstream and ofstream data types do not?
What do you think about this solution?
We value your feedback to improve our textbook solutions.