Question: can someone fix this code I get errors inside the natural merge function I get error 0 E 4 1 3 here is the code

can someone fix this code I get errors inside the natural merge function I get error 0E413 here is the code below ??? test function for the binary/herge function
string infile1, infilez, buffer, outfile;
int nergeDepth;
// comand line parameters: infile1, infile2, mergeDepth, autfile
if (argc --5)
#include
#include
#include
#include
using namespace std;
bool binaryMerge(ifstream& if1, ifstream& if2, int mergeDepth, ofstream& of){
// preconditions: infile1, infile2, and outfile must be valid file streams, and must be open
// if they are not this function will read and/or write garbage
int count1=1;
int count2=1;
bool file1= true;
bool file2= true;
int buffer1, buffer2;
if (if1>> buffer1){
// we tried to read from the stream in the argument to the if statement
// if successful, the result is true
// if not the result is false and we go to the else clause and flag this file as done
}
else {
// we are at the end of file 1
file1= false;
}
if (if2>> buffer2){
// we tried to read from the stream in the argument to the if statement
// if successful, the result is true
// if not the result is false and we go to the else clause and flag this file as done
}
else {
// we are at the end of file 2
file2= false;
}
if (!file1 && !file2){
// both files are at the End Of File marker, there is nothing to merge
// return false to let the caller know that the merge has been completed
// note that it is the caller's job to close all of the streams
return false;
}
// this block is entered only if both files are not yet at the EOF marker
if (file1 && file2){
// both files are good, and we've already loaded up both of the buffers
while (true){
if (buffer1 buffer2){
count1++; // bump the depth counter for this file
of buffer1; // write that element to the output file
of ""; // and a space to separate the numbers
// now we have to see if there is something else to read
if (count1= mergeDepth && if1>> buffer1){
// no code here
}
else {
file1= false;
break; // either f1 is at EOF or we have read the last item for that merge depth
}
}
else {
count2++; // bump the depth counter for this file
of buffer2; // write that element to the output file
of ""; // and a space to separate the numbers
if (count2= mergeDepth && if2>> buffer2){
// no code here
}
else {
file2= false;
break; // either f2 is at EOF or we have read the last item for that merge depth
}
}
}
}
// at this point either one of the files is at EOF, or one of the depth counts has passed mergeDepth
if (file2){// file1 is dry, read the rest of file2 up to either merge depth or end of file, whichever comes first
of buffer2""; // take care of the item read previously
count2++; // bump the counter
while (count2= mergeDepth && if2>> buffer2){
// read and write until either EOF or depth reached
of buffer2"";
count2++;
}
}
else {
of buffer1"";
count1++;
while (count1= mergeDepth && if1>> buffer1){
of buffer1"";
count1++;
}
}
if1.close();
if2.close();
of.close();
// merge complete!
return true;
}
bool naturalMerge(ifstream& if1, ifstream& if2, int mergeDepth, ofstream& of){
int buffer1, buffer2;
bool file1= if1>> buffer1; // Attempt to read first element from if1
bool file2= if2>> buffer2; // Attempt to read first element from if2
int last1= INT_MIN, last2= INT_MIN; // Initialize to minimum int value
while (file1 && file2){// While there are elements in both files
if ((buffer1 buffer2 && buffer1>= last1)|| last2> buffer2){
// If buffer1 is less than buffer2 and is part of a run, or buffer2 has ended a run
of buffer1"";
last1= buffer1; // Update last1 to the last written value from if1
file1= if1>> buffer1; // Read next element from if1
}
else {
of buffer2"";
last2= buffer2; // Update last2 to the last written value from if2
file2= if2>> buffer2; // Read next element from if2
}
}
// If one file is exhausted, output the rest of the other file
while (file1){// If elements remain in if1
if (buffer1>= last1){// If the current element continues the run
of buffer1"";
last1= buffer1;
file1= if1>> buffer1;
}
else {
break; // Run ended, exit the loop
}
}
while (file2){// If elements remain in if2
if (buffer2>= last2){// If the current element continues the run
of buffer2"";
last2= buffer2;
file2= if2>> buffer2;
}
else {
break; // Run ended, exit the loop
}
}
return file1|| file2; // Return true if at least one file had elements left
}
int main(int argc, char* argv[]){
// test function for the binaryMerg
 can someone fix this code I get errors inside the natural

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 Databases Questions!