0

Whenever is give N = 1e6 + 2 like large value to N. VS Code doesn't work and on runtime shows .exe stopped working. Couldn't figure out why happening

#include <iostream>
using namespace std;
int main()
{
int n, arr[n];
cin >> n;
for (int i = 0; i < n; i++)
{
    cin >> arr[i];
}
int N = 1e6 + 2;
bool check[N];

for (int i = 0; i < N; i++)
{
    check[i] = false;
}

return 0;
}
Jason
  • 36,170
  • 5
  • 26
  • 60
  • most likely your problem is `arr[n]` – rioV8 May 31 '22 at 08:39
  • While all the dupes correctly point out the problems with VLAs like `arr` and `check`, please note that the posted code has another problem: `int n, arr[n]; cin >> n;`. Here `n` is used uninitialized, when its value is undeterminated. – Bob__ May 31 '22 at 09:05

0 Answers0