I'm running the Pigeonhole Sort code which using C++, and use the VS2017 and VS code to compiler. That creates an array of vectors. Size of array range. It had not worked in VS2017 but it had work in VS code. What's wrong between two editors?
I do the following
int arr[] = { 8, 3, 2, 7, 4, 6, 8 };
int n = sizeof(arr) / sizeof(arr[0]);
printf("Sorted order is : ");
for (int i = 0; i < n; i++)
printf("%d ", arr[i]);
int min = arr[0], max = arr[0];
for (int i = 1; i < n; i++) {
if (arr[i] < min)
min = arr[i];
if (arr[i] > max)
max = arr[i];
}
int range = max - min + 1;
vector<int> holes[range];
for (int i = 0; i < n; i++)
holes[arr[i] - min].push_back(arr[i]);
int index = 0;
for (int i = 0; i < range; i++) {
vector<int>::iterator it;
for (it = holes[i].begin(); it != holes[i].end(); ++it)
arr[index++] = *it;
the code vector holes[range] can run in VS code but it can not run in VS2017. It was an error when it complier in VS2017 like this: error: expression must have a constant value. What's the problem in here and how to debug? please help me!