0

hello i just to know how to define an array...
when using a variable...
for example...

cin >> numb;

int an_array[numb]

when i try it...it tells me
cannot allocate an array of constant size 0
and
unknown size
...
so could you please tell me how do it ???

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by MosaicFuneral
0

Arrays have to be constant.

Try vector<int>, or allocate the memory and delete it at the end.

int *an_array;

 /*input*/

an_array = new int [numb];

/*stuff*/

delete [] an_array;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.