home *** CD-ROM | disk | FTP | other *** search
- // ex03003.cpp
- // the C++ free store: new with a dynamic array
- #include <iostream.h>
- #include <stdlib.h>
-
- main()
- {
- cout << "Enter the array size: ";
- int size;
- cin >> size; // get the array size
- int *array = new int[size]; // allocate an array
- for (int i = 0; i < size; i++) // load the array
- array[i] = rand(); // with random numbers
- for (i = 0; i < size; i++) // display the array
- cout << '\n' << array[i];
- delete array; // return the array to the free store
- }