gpt4 book ai didi

c++ - 非常量大小的数组 : Why does this even work?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:39:37 24 4
gpt4 key购买 nike

<分区>

#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;
}

这是某种动态分配吗?
为什么它甚至不给出“n”为“const”的错误?

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

我正在使用 Dev-C++。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com