This is the code I have now but it freezes up after the first input:
#include <iostream> using namespace std; void main(void) { int* myArray = NULL; int* myNewArray = NULL; int i = 0; int input = 0; bool breakLoop = false; while(!breakLoop) { cout << "Enter a positive integer: " << endl; cin >> input; i++; if(input > 0) { myNewArray = new int[i]; for(int x = 0; x < i; x++) { myNewArray[x] = myArray[x]; } myNewArray[i-1] = input; } breakLoop = input < 0; } for(int j = 0; j < i; j++) { cout << myArray[j] << endl; } delete [] myArray; }
If it helps this is a computing science lab. Here's the webpage for it, it's problem #2:
http://www.cs.sfu.ca.../lab8/lab8.html
Edited by Melchoire, 08 November 2009 - 09:07 PM.