I am took two arrays and then merged those two arrays to a newly created third array and it worked but when I output the size of the array, I was getting the size as '1'. I don't understand why the size of that array was '1' even though there are 5 elements in it.
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int arr1[] = { 1,2,3 };
int arr2[] = { 9,4 };
int size1 = sizeof(arr1) / sizeof(int);
int size2 = sizeof(arr2) / sizeof(int);
int *arr = new int[size1 + size2];
//merging the two arrays by transferinng the elements into the third array
for (int i = 0; i < size1; i++)
{
arr[i] = arr1[i];
}
for (int i = size1; i < (size1 + size2); i++)
{
arr[i] = arr2[i - size1];
}
//sorting the array
sort(arr, arr + (size1 + size2));
cout << endl;
//finding the size of newly merged array
int mergeSize = sizeof(arr) / sizeof(int);
cout << "The size of the array is " << mergeSize << endl; //why am I getting the size of the array as '1'
return 0;
}