【发布时间】:2011-08-16 13:58:20
【问题描述】:
此代码在 Bloodshed Dev-C++ 4.9.9.2 中编译良好,但在 Visual Studio 2010 中出现错误:表达式必须具有常量值。如何在用户输入数组大小后不使用指针创建数组?
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int size = 1;
cout << "Input array size ";
cin >> size;
int array1[size];
system("PAUSE");
return 0;
}
【问题讨论】:
标签: c++ visual-studio arrays input dev-c++