A
Ali
Hi,
I want to create an array, whose size should be entered by the user,
instead of me hardcoding it on the code.
The following is what i want to do:
#include <iostream.h>
int main()
{
int numElements=0;
cin>>numElements;
int Array[numElements];
//do something
return 0;
}
The compiler gives an error asking for a constant, such as int
Array[5], etc.
How do i solve the problem, if i want to let the user choose the Array
Size?
Thanks,
Ali
I want to create an array, whose size should be entered by the user,
instead of me hardcoding it on the code.
The following is what i want to do:
#include <iostream.h>
int main()
{
int numElements=0;
cin>>numElements;
int Array[numElements];
//do something
return 0;
}
The compiler gives an error asking for a constant, such as int
Array[5], etc.
How do i solve the problem, if i want to let the user choose the Array
Size?
Thanks,
Ali