As TheIdeasMan said a vector would be a better choice, but to use what you have if that is what you need:
1 2 3 4 5 6 7 8 9 10 11
# include <iostream>
usingnamespace std;
int main()
{
constexprint N{ 20 }; // <--- The {}s do the same as "= 20"
int arr[N]; //error n must be constant
return 0;
}
The capital letter "N" helps to let you know it is defined as a constant. And this is the way it is done most often.