Question
I need this template followed for this question Write a program that merges the numbers in two files and writes all the numbers into a
I need this template followed for this question
Write a program that merges the numbers in two files and writes all the numbers into a third file. Your program takes input from two different files and writes its output to a third file. Each input file contains a list of numbers of type int in sorted order from the smallest to the largest. After the program is run, the output file will contain all the numbers in the two input files in one longer list in sorted order from smallest to largest. Your program should define a function that is called with the two input-file streams and the output-file stream as three arguments. If this is being done as a class assignment, obtain the file names from your instructor. The template is linked above, the input file names for this question are week1.tx tand week2.txt , Output file name is outName4.txt
Question:
Template:
#include
using namespace std;
void merge(ifstream& input1, ifstream& input2, ofstream& output);
// Precondition:
// The input files are text files.
// The input files have been opened.
// The input files contain ASCII encodings of int objects
// separated by white space The int objects represented are
// in increasing order.
// Postcondition: The output file created is a file
// containing ASCII encoding of int objects separated by
// white space. The int objects are in increasing order
.int main()
{
ifstream infile1, infile2;
ofstream outfile;
char inName1[13], inName2[13], outName[13];
outName[13]="outName";
cout << "While Entering file names,"
<< " please restrict the file name "
<< "to 8 characters, a . , followed by "
<< " at most a 3 letter "
<< " extension. (MS DOS/Windows 3.1 "
<< " restriction.) ";
cout << "Enter the first of two input file names: "
<< endl;
cin >> inName1;
cout << "Now a second input file name " << endl;
cin >> inName2;cout << "Enter the output file name. " << endl
<< "WARNING: ANY EXISTING FILE WITH THIS NAME WILL"
<<" BE ERASED." << endl;
cin >> outName;
//closing files prior to reopening them for display
//must open file outName as an ifstream to read it.cout << "Contents of file "
<< inName1 << " are: " << endl;
txt file
week1
22
44
55
77
99
week2
11
55
101
OUTPUT TO outName4.txt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started