int* p = new int[10]()
should do.
However, as Michael points out, using std::vector
would be better.
More Related Contents:
- Initialization of all elements of an array to one default value in C++?
- Array[n] vs Array[10] – Initializing array with variable vs numeric literal
- How to emulate C array initialization “int arr[] = { e1, e2, e3, … }” behaviour with std::array?
- How to initialize std::array elegantly if T is not default constructible?
- C++11: Correct std::array initialization?
- Now that we have std::array what uses are left for C-style arrays?
- too many initializers for ‘int [0]’ c++
- Is there a way to statically-initialize a dynamically-allocated array in C++?
- Why can’t I initialize a variable-sized array?
- Invalid operands to binary expression while implementing vector [closed]
- For loop with an array
- Difficulties on atributting a array to another [closed]
- can’t extract data from a structure array c++ [closed]
- How would I implement Arrays into this code
- How to return an array from a function?
- Can placement new for arrays be used in a portable way?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- How do you initialise a dynamic array in C++?
- Finding smallest value in an array most efficiently
- In C, why can’t I assign a string to a char array after it’s declared?
- Passing array of structures to function c++
- What is the use of 0-length array (or std::array)?
- can’t modify char* – Memory access violation
- initialization: parenthesis vs. equals sign [duplicate]
- What’s the difference between parentheses and braces in c++ when constructing objects
- Parse string containing numbers into integer array
- difference between pointer to an array and pointer to the first element of an array
- Array of size defined by not constant variable
- What’s the motivation behind having copy and direct initialization behave differently?
- int *array = new int[n]; what is this function actually doing?