Dontony's blog

By Dontony, history, 4 years ago, In English

Can we create an array of size 1e6+1 in C++(in my IDE the code crashes),by any methods,or, using vectors would be better? Please comment on this!Thanks.

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I think you should cast it as an integer like (int)(1e6+1). Probably post code for better help :)

»
4 years ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

Declare the array in the global. It's because when you declare variables inside a function, its limited to the stack size. And I think your IDE set the stack size smaller.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It worked by declaring the array as global.Thanks!