int main()
{ vector<int> ivec;
int ix;
while(cin>>ix)ivec.push_back(ix);
int iarray[ivec.size()];
...// do something with iarray
}
My understanding: array size should be determined at compile time, in this code the ivec.size() is not known till run time, so is it safe to do so? I checked with a short code and it works.
Oh, it's perfectly safe to do so for the purposes of making an executable that runs on your system. It's just not proper C++ (yet), yet despite that many C++ compilers support it. I'd stick to proper C++ to ensure that your code will compile with any proper working C++ compiler. :)