c++ - How to create an array with number of elements from a variable? -
this question has reply here:
variable length arrays in c++? 14 answersi have integer num
read file. want create array number of elements beingness num
.
a sample code of want doesn't work:
int num; cin >> num; int iarray[num];
arrays in c++ have compile-time bounds.
use dynamic allocation instead, or healthy std::vector
wrapper around same process.
c++ arrays
No comments:
Post a Comment