このコードは 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;
}