I have a feeling my logic is off here.....crashes randomly depending on input
//Exc_6.cpp - practice with arrays
#include<iostream>
using namespace std;
void fillArray(double array[], int size);
void showArray(const double array[], int size);
void reverseTheArray(double array[], double reveseArray[], int size);
int main()
{
int size;
cout << "Please enter the size of an array: ";
cin >> size;
double **array;
double **reverseArray;
array = new double *[size];
reverseArray = new double *[size];
fillArray(*array, size);
cout << "Displaying array." << endl;
showArray(*array, size);
cout << "Reversing array." << endl;
reverseTheArray(*array, *reverseArray, size);
cout << "Result of reversed array." << endl;
showArray(*reverseArray, size);
system("PAUSE");
//delete array;
//delete reverseArray;
}
void fillArray(double array[], int size)
{
double temp;
for (int i = 0; i < size; i++)
{
cout << "Input a double number: ";
cin >> temp;
array[i] = temp;
}
}
void showArray(const double array[], int size)
{
for (int i = 0; i < size; i++)
cout << "Array slot " << i+1 << " contains " << array[i] << endl;
}
void reverseTheArray(double array[], double reverseArray[], int size)
{
int count;
count = size;
for (int i = 0; count > 0; count--, i++)
reverseArray[i] = array[count];
}