I need to create a program where the user enters the desired size of an array and the C++ code then creates it and subsequently allows data entry into it.
This works in the Code Blocks IDE but not in Visual Studio Community 2015
When I put the following code in CodeBlocks Version 13.12 it works
#include<iostream>
using namespace std;
int main()
{
int count;
cout << "Making the Array" << endl;
cout << "How many elements in the array " << endl;
cin >> count;
int flex_array[count];
for (int i = 0; i < count; i = i + 1)
{
cout << "Enter the " << i << " term " << endl;
cin >> flex_array[i];
}
for (int j = 0; j < count; j = j + 1)
{
cout << "The " << j << " th term has the value " << flex_array[j] << endl;
}
return 0;
}
However, if I enter the same code in Visual Studio 2015 (i.e. Version 14.0.25425), I get the error:
expression must have a constant value
Any idea why this occurs?