Question: Program 8 . 2 #include #include #include / / needed for exit ( ) using namespace std; int main ( ) { what does this

Program 8.2
#include
#include
#include // needed for exit()
using namespace std;
int main()
{
what does this code mean
ifstream inFile;
ofstream outFile;
inFile.open("prices.dat"); // attempt to open the file for input
char response;
if (!inFile.fail())// if it doesn't fail, the file exists
{
cout "A file by the name prices.dat exists.
"
"Do you want to continue and overwrite it
"
" with the new data (y or n): ";
cin >> response;
if (tolower(response)=='n')
{
cout "The existing file will not be overwritten." endl;
exit(1); //terminate program execution
}
}
outFile.open("prices.dat"); // now open the file for writing
if (inFile.fail())// check for a successful open
{
cout "
The file was not successfully opened"
endl;
exit(1);
}
cout "The file has been successfully opened for output."
endl;
// statements to write to the file would be placed here
return 0;
}
Program 8 . 2 #include #include #include / /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!