1int main()
2{
3 int size;
4
5 std::cin >> size;
6
7 int *array = new int[size];
8
9 delete [] array;
10
11 return 0;
12}
1int* a = NULL; // Pointer to int, initialize to nothing.
2int n; // Size needed for array
3cin >> n; // Read in the size
4a = new int[n]; // Allocate n ints and save ptr in a.
5for (int i=0; i<n; i++) {
6 a[i] = 0; // Initialize all elements to zero.
7}
8. . . // Use a as a normal array
9delete [] a; // When done, free memory pointed to by a.
10a = NULL; // Clear a to prevent using invalid memory reference.
11