int* arrayName = newint[9001]; //it's over 9000!
//... eventually after you are finished with arrayName...
delete[] arrayName;
2. Declare a multidimensional dynamic array
1 2 3 4 5 6 7 8 9
int** multiDim = newint*[5];
for(int i = 0; i < 5; ++i) {
multiDim[i] = newint[10]; //so each of the "rows" will have 10 ints
}
//... and later ...
for(int i = 0; i < 5; ++i) {
delete[] multiDim[i];
}
delete[] multiDim;
3. Fill these arrays
4. Display these arrays
1 2 3 4 5 6 7 8 9 10 11 12 13
//Filling and displaying are kind of the same thing
//Let's pretend I already created arrayName and multiDim
for(int i = 0; i < 9001; ++i) {
arrayName[i] = i;
std::cout << i << " ";
}
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < 10; ++j) {
array[i][j] = 5*i + j;
std::cout << array[i][j] << " ";
}
std::cout << "\n";
}