int length;
cin>>length;
int arr[length][2];
比如这个,length 待输入,编译器在为 arr 分配空间的时候,遇到length怎么办,是直接把length当成int的最大值来分配吗?
g++ ,我也很奇怪,不能理解为什么
ringa_lee2017-04-17 14:29:02
This is a new addition to the c99 specification, a variable-length array. The length of the array is determined during runtime and cannot be changed once determined.
You can check out this blog: http://rangercyh.blog.51cto.c...
黄舟2017-04-17 14:29:02
I use vs2012, which does not support variable length arrays. It seems that the latest C++ standard supports it, but I have never seen any compiler support it