I have a function declared like this
int * return_array(int * arr1 , int * arr2); and the function is defined like this
int * return_array(int * arr1, int * arr2) { int arr_sum[5]={0}; int count = 0; do { arr_sum[count] = *(arr1+count)+*(arr2+count); count ++; } while (count < 5); return (arr_sum); } this is how i am trying to access the returned array in the main function
int *get_arr; get_arr=return_array(arr1,arr2); cout << "Their sum is :" << endl; for (count = 0; count < 5; ++count) { cout << *(get_arr+count) << endl; } the first sum is correct but the rest looks to be garbage values, what might be the cause?
std::array<int, 5>