Good evening, I try to create a C ++ program that combines arrays in for and switch; however, I mark error in the declaration of the variable numbers [p], I know that it is because the number between the brackets must be a constant. My question is, is there any way to declare a constant NO value within the brackets? In advance, thank you.
#include <iostream>
int n,p,c,numero;
int numeros[p];
using namespace std;
{
void CrearArreglo()
{
{
cout<<"Inserta el numero de indices que quieres que tenga tu arreglo (entre 5 y 20)"<<endl;
cin>>n;
}
}
void LlenarArreglo()
{
int numeros[p];
for(int p=0;p<n;p++)
{
cout<<"Introduce un numero"<<endl;
cin>>numero;
numeros[p]=numero;
}
}
int main()
{
do{
cout<<"Elige una opcion"<<endl;
cout<<"0 Salir"<<endl;
cout<<"1 Crear arreglo"<<endl;
cout<<"2 Llenar arreglo"<<endl;
cin>>c;
switch(c)
{
case 1:
{
CrearArreglo();
}
break;
case 2:
{
LlenarArreglo();
}
break;
}
}while(c!=0);
}
}