小编Luc*_*cky的帖子

非恒定大小的数组:为什么这甚至可以工作?

#include <iostream>
using namespace std;

int main(){
    int n;
    cout<<"Enter the size :";
    cin>>n;
    int array[n];  // I've worked some outputs and it works 
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是某种动态分配吗?
为什么它甚至没有给'n'作为"const"的错误?

此外,写入cout << array[n+5];不会导致编译时或运行时错误.

我正在使用Dev-C++.

c++ memory arrays compiler-errors dynamic

5
推荐指数
1
解决办法
194
查看次数

标签 统计

arrays ×1

c++ ×1

compiler-errors ×1

dynamic ×1

memory ×1