srand(time(NULL)); /* You need to set up a random generator in order to use random numbers */
int numberOfInts = 0;
cout << "Number of integers you want to use?\n:";
cin >> numberOfInts;
myArr = newint[ numberOfInts ];
cerr<<"OH NO! An error occurred allocating the memory for this array!";
for(int i = 0; i < numberOfInts; i++)
myArr[ i+1 ] = rand()%100 +1; /* <---- generates a random number form 1 to 100 */
while(numberOfInts > 0)
cout << myArr[ numberOfInts ] << " ";
delete myArr; // must delete allocated pointer!
delete myArr; // must delete contents of created array!
The exception handling was designed to be an example not an actual finished product, and as for the deletion error I've been programming with Java for quite some time and need to shake off the rust in C++, but I see what your getting at, thanks.