dhyaan's blog

By dhyaan, history, 5 years ago, In English

When I declare vector v[10] , inside the main() function like this,


#include<bits/stdc++.h> int main() { vector<int> v[10]; }

the program halts & stops responding.

But When I declare it at global, like this,

#include<bits/stdc++.h>
vector<int> v[10];
int main()
{
    //something
} 

It works fine.

Why ?

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It works on my pc, as well as on custom test which you can check here: https://codeforces.com/problemset/customtest

It probably depends on the compiler, so try updating them (I use C++17).

»
5 years ago, # |
  Vote: I like it +16 Vote: I do not like it

Is 10 a bigger number? If so it may be possible that there aren't enough space on stack.