Can't seem to access the required elements in the following code. Pretty simplistic program, but hey... gotta start somewhere right?
Code:#include <iostream.h> float* mirror(float[], int); void main(void) { const int size = 5; float numbers[size] = {1.0, 2.0, 3.0, 4.0, 5.0}; cout << "The numbers before mirror() are..." << endl; for(int i = 0; i < size; i++) { cout << numbers[i] << " "; } cout << endl; cout << "The numbers after mirror() are..." << endl; for(i = 0; i < size; i++) { cout << mirror(numbers, size) << " "; } } float* mirror(float p[], int arraySize) { int i; float* tempArray = new float[arraySize]; for(i = 0; i < arraySize; i++) tempArray[i] = p[(arraySize - 1) - 1]; return tempArray; }




Reply With Quote