Is it possible to allow the user to enter the size of an array with a keyboard?
I know that arrays can\'t change size. The only solution I could think of is this:
No, you can't have dynamic allocations like that on the stack (yes, I know, some compilers have extensions for this, but generally speaking the answer is no). You'd want to use malloc
or new
to dynamically allocate room on the heap. Or of course there are always structures to make life easier, like vector.