#include <iostream> #include <fstream> #include <cstdlib> using namespace std; /
ID: 3618959 • Letter: #
Question
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
//These functions explained below
void spaces();
void introduction();
int main()
{
ifstream infile, infile2;
ofstream outfile;
int numbers,number;
char response;
do
{
infile.open("one.txt");
if(infile.fail())
{
cout << "I could not open thatfile.";
exit(1);
}
infile2.open("two.txt");
if(infile2.fail())
{
cout << "I could not open thatfile.";
exit(1);
}
outfile.open("both.txt");
if(outfile.fail())
{
cout << "I could not open thatfile.";
exit(1);
}
while(!infile.eof())
{
bool less=false;
infile >> number;
while(!infile2.eof())
{
infile2 >> numbers;
if(number < numbers)
{
outfile << number;
less = true;
}
if(less == true)
outfile << numbers;
}
}
infile.close();
infile.clear();
infile2.close();
infile2.clear();
outfile.close();
//Asks the user he would like to go again anything other than (Y ory) the program ends
cout << "Would you like to go again (Yor y): ";
cin >> response;
cout << endl;
}while(response == 'Y' || response== 'y');
return 0;
}
//This void function is for 2 statement spaces betweensentences
void spaces()
{
cout << endl << endl;
}
Explanation / Answer
please rate - thanks basically your files each have only 1 number in each. youmust have whitespaces between each number. in addition you don't allow for the files having a different numberof numbers in each I'm messaging you my answer to this problem--don't peak
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.