Create an array in a function in C++ without a global variable
<p>So I would like to create an array in a function with the size set by a number coming in as the parameter. Here is an example:</p>

<pre><code>void temp_arr ( const int array_size ) {
     int temp_arr[array_size]; //ERROR array_size needs to be a constant value
    //Then do something with the temp arr
}
</code></pre>

<p>Even if the parameter is a const int, it will not work. I would like to not use a global const and not use vectors. I am just curious as I am learning C++. I would like for it to make it so that the array size is different each time the function is called. Is there a solution to this or am I to create a const variable and the array before the function is called? </p>