Question: Variables dataFileName, data 1 , data 2 , data 3 , data 4 , and data 5 , are read from input. Perform the following
Variables dataFileName, data data data data and data are read from input. Perform the following tasks:
Open dataFileName as the output file.
If the output file fails to open, then use cout to output dataFileName followed by : error opening file" and a newline. Then, terminate the program with as the return value.
Otherwise, for strings data data data data and data write followed by the string and and a newline to the output file.
Close the file.
Ex: If the input is locationData.txt then locationData.txt contains:
#include
#include
using namespace std;
int main
ofstream locationFS;
string dataFileName;
string data;
string data;
string data;
string data;
string data;
cin dataFileName;
cin data;
cin data;
cin data;
cin data;
cin data;
Your code goes here
if locationFSisopen For testing purpose only
locationFS "File is not closed." endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
