Write a program that will read the two input files "input1.txt" and "input2.txt", which contain only integers. The program should form one output file "output.txt". The program should combine both input files into one output file. The program should compare the numbers read from both files. Write a smaller number in the first column and a larger number in the second. In the third column, write in which file there was a smaller number. If they were the same, write "same" in the third column.
I'm having problems with this program, because first of all I'm a beginner and I'm still learning. Here is my code so far, it's not complete but I don't know what to do next.
int number1, number2, counter1 = 0, counter2 = 0, pom = 0;
ifstream input1;
ifstream input2;
ofstream output;
while (input1 >> number1) {
counter1++;
output << number1 << " ";
}
while (input2 >> number2) {
counter2++;
output << number2 << " ";
}
if (counter1 > counter2)
pom = number1;
for (int i = 0; i < counter1; i++) {
input1 >> number1;
input2 >> number2;
if (number1 < number2)
{
output << number1 << number2;
output << "First" << "\n";
}
else if (number1 > number2)
{
number1 = number2;
number2 = pom;
output << number1 << number2;
output << "Second" << "\n";
}
else
{
output << number1 << number2;
output << "Same" << "\n";
}
}
input1.close();
input2.close();
output.close();
return 0;