The task is to copy the contents of the first array and second array into the third array and display it. I'm getting garbage values when I try this. What am I doing wrong? Thanks.
- input1.txt= How are you doing
- input2.txt= today sir
#include <iostream>
#include <fstream>
using namespace std; 
void display(char* ptr, int size)
{ 
    for (int i = 0; i < size; i++)
    { 
        cout << ptr[i]<< " "; 
    } 
    cout << endl; 
}
int main() 
{ 
    ifstream fin1; 
    fin1.open("input1.txt"); 
    int size1 = 0; 
    while (!fin1.eof()) 
    {
        fin1.get(); size1++; 
    } 
    char* arr1 = new char[size1]; 
    fin1.close(); 
    fin1.open("input1.txt"); 
    fin1.getline(arr1, size1); 
    ifstream fin2; 
    fin2.open("input2.txt"); 
    int size2 = 0; 
    
    while (!fin2.eof())
    { 
        fin2.get(); size2++; 
    } 
    char* arr2 = new char[size2]; 
    fin2.close(); 
    fin2.open("input2.txt"); 
    fin2.getline(arr2, size2); 
    int size3 = size1 + size2; 
    char* arr3 = new char[size3 + 2]; 
    return 0; 
}
 
    