I'm trying to concatenate two arrays that were initialized from file input into one dynamic array and returning it to an output file but while testing I found out that the returned dynamic array is initialized with random numbers. I'm sorry for my lack of experience as I am a beginner.. These are my input text files
Input1.txt
1
2
3
Input2.txt
4
5
6
and this is my code ..
#include <iostream>
#include <fstream>
using namespace std;
int * concatenate(int *a1,int *a2,int size);
int main() {
    int size = 3;
    int arr1[size];
    int arr2[size];
    ifstream fin;
    ofstream fout;
    fin.open("input1.txt");
    for(int i = 0; i < size; i++) {
        int value;
        fin>>arr1[i];
        cout<<arr1[i]<<endl;
    }
   fin.close();
    
    fin.open("input2.txt");
    for(int j = 0; j < size; j++) {
        fin>>arr2[j];
        cout<<arr2[j]<<endl;
    }
   
    int *arr3 = concatenate(arr1,arr2,size);
    cout<<arr3[1];
    return 0;
}
int * concatenate(int *a1,int *a2,int size) {
    int * r = new int[size*2];
    for(int i = 0; i > size*2; i++) {
        if(i < size)
            r[i] = a1[i];
        else
            r[i] = a2[i-size];
    }
    return r;
    
}
 
     
     
    