Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Variables dataFileName, data 1 , data 2 , data 3 , data 4 , and data 5 , are read from input. Perform the following

Variables dataFileName, data1, data2, data3, data4, and data5, 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 1 as the return value.
Otherwise, for strings data1, data2, data3, data4, and data5, write "+" followed by the string and "+" and a newline to the output file.
Close the file.
Ex: If the input is locationData.txt 6398478876619405200466560, then locationData.txt contains:
+63984+
+78876+
+61940+
+52004+
+66560+
#include
#include
using namespace std;
int main(){
ofstream locationFS;
string dataFileName;
string data1;
string data2;
string data3;
string data4;
string data5;
cin >> dataFileName;
cin >> data1;
cin >> data2;
cin >> data3;
cin >> data4;
cin >> data5;
/* Your code goes here */
if (locationFS.is_open()){/* For testing purpose only */
locationFS << "File is not closed." << endl;
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

What is a goal? (p. 86)

Answered: 1 week ago