int main()
{
int size;
std::cin >> size;
int *array = new int[size];
delete [] array;
return 0;
}
Don’t forget to delete
every array you allocate with new
.
More Related Contents:
- Determine if a variable is less than 0 without if statement [closed]
- Copy a file in a sane, safe and efficient way
- Why should the copy constructor accept its parameter by reference in C++?
- Are inline virtual functions really a non-sense?
- How do promotion rules work when the signedness on either side of a binary operator differ? [duplicate]
- Why do C and C++ support memberwise assignment of arrays within structs, but not generally?
- Forward declaration of a typedef in C++
- What is Proxy Class in C++
- When do function-level static variables get allocated/initialized?
- Calculating normals in a triangle mesh
- const int = int const?
- CRTP to avoid dynamic polymorphism
- regex replace with callback in c++11?
- Is it safe to push_back an element from the same vector?
- gcc: undefined reference to
- C++17 class template partial deduction
- Make QWidget transparent
- Template class with template container
- How to have two functions that call each other C++
- Convert lptstr to char*
- Fatal error: “No Target Architecture” in Visual Studio
- Visual Studio 2010 & 2008 can’t handle source files with identical names in different folders?
- Why don’t std::vector’s elements need a default constructor?
- Declaring a pointer to multidimensional array and allocating the array
- Can I use #include “pch.h” instead of #include “stdafx.h” as my precompile header in Visual Studio C++?
- What is the difference between string::at and string::operator[]?
- In c++ 11, how to invoke an arbitrary callable object?
- C++11 std::mutex in Visual Studio 2012 deadlock when locked from DllMain()
- Portable Compare And Swap (atomic operations) C/C++ library?
- Can I treat a specific warning as an error?