1

Sorry for the dumb question (I'm a total C++ noob), but what does

int x[101010];

declare? Is it list, a vector et cetera? And what is the meaning of 101010? I have never seen a declaration like this.

Kurns
  • 157
  • 10
  • 2
    An array of `int` with 101010 elements – midor Jul 09 '18 at 12:24
  • Got it. Should I delete the question or let it be? – Kurns Jul 09 '18 at 12:25
  • You can let it be, or post an answer yourself. – MivVG Jul 09 '18 at 12:27
  • `x` is `variable` of `int` Array, number between **[** and **]** is count of elements. – AleXelton Jul 09 '18 at 12:27
  • 3
    I will start a close vote. I think your question is justified, but with this title and content it is unlikley that anyone with the same issue will find it, and I don't know a good change to amend it. Also there is a general FAQ here: https://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c – midor Jul 09 '18 at 12:37

1 Answers1

3

At block scope, int x[101010]; declares a uninitialised array with 101010 elements.

At global scope, the effect is similar but the elements are set to 0.

Note that if you had written int x[010101];, then you would have created 4161 elements as a leading 0 denotes an octal literal in C++.

In C++, a good rule of thumb is to use a std::vector unless you have a good reason not to.

StoryTeller - Unslander Monica
  • 165,132
  • 21
  • 377
  • 458
Bathsheba
  • 231,907
  • 34
  • 361
  • 483