#include using namespace std; // what's the other way I could do this, without using a return type? // is it any 'cleaner'? int* doubleSize(int* anArray, int & size) { int i; int* arrayToReturn; size = size * 2; arrayToReturn = new int[size]; // copy over, back to back versions of original array for (i = 0; i < size; i++) { arrayToReturn[i] = anArray[i % (size/2)]; } delete [] anArray; return arrayToReturn; } int main(int argc, char* argv[]) { int i; int requestedSize; int* theArray; cout << "How many integers do you need to hold? "; cin >> requestedSize; theArray = new int[requestedSize]; for (i = 0; i < requestedSize; i++) { theArray[i] = i; } theArray = doubleSize(theArray,requestedSize); cout << "Bam! Now you've got space for twice as many integers..." << endl; for (i = 0; i < requestedSize; i++) { cout << theArray[i] << " "; } cout << endl; delete [] theArray; }