Array Size

Is there any way in which the size of array is assigned on the basis of user's choice?
I know only variables of type const can be used for declaring array of a particular size, but how do I do it when the size depends on value entered by user?
I suggest you could use vectors instead.

http://www.cplusplus.com/reference/stl/vector/
you cannot do it with array use vector instead
You can also do it with new, but don't forget to use delete.

http://www.cplusplus.com/doc/tutorial/dynamic.html
Thanks
You could also use malloc if you wanted, but elpis and mordekai posted much better solutions ;p.
malloc is a C style of memory allocation. better to recommend the use of new/delete instead.

Again, A vector is a better method.
Topic archived. No new replies allowed.