i wrote some code to take an array and run it through a function to reverse the elements of the array and then return a pointer to the new array. For some reason im not getting the results i want. It has to do with my reverseArray function. Specifically in my for loop because when i hard code my new array i get the numbers i want. I would like to avoid hard coding them. any advise??
#include<iostream>
using namespace std;
int* reverseArray(int,int[]);
void showArray(int[], int);
int main()
{
const int SIZE = 5;
int* fixedArray;
int test[SIZE] = {10, 20, 30, 40, 50};
int* arrayPtr;
fixedArray = reverseArray(SIZE, test);
cout << "Here is the original array: " << endl;
showArray(test,SIZE);
cout << "Here is the new array: " << endl;
showArray(fixedArray, SIZE);
}
int* reverseArray(int size,int score[])
{
int* revArray;
int count;
int index;
revArray = new int[size];
for(count = 5;count = 0;count--)
{
index = 0;
revArray[index] = score[count];
index++;
}
return revArray;
}
void showArray(int score[], int size)
{
for(int index = 0; index < size; index++)
{
cout << score[index] << " " << endl;
}
}