int main()
{
int size;
std::cin >> size;
int *array = new int[size];
delete [] array;
return 0;
}
//A dynamic array is a pointer that contains multiple objects or pointers.
int size = 5; //Size of the array
/*
"new" keyword tells your computer to allocate memory
and return a pointer to that memory.
*/
int* array = new int[size];
int* array = new int[size] { 5, 6, 1, 2, 8 }; //Optional initializer
/*
Always use delete or delete[] to free a dynamic pointer.
Do not use to free a pointer or an array that was not created with
"new" or "malloc()"
NOTE: delete frees a pointer whereas delete[] removes an array.
*/
delete[] array;
int *array = new int[size];