C ++ arrays and size

If I have, for example, the following array declaration:, int a[5];this means that I have an array "a" that contains 5 integer variables .

Would there be something like this in your memory (see \0)?


| 0 | 1 | 2 | 3 | 4 | \ 0 |

So, in this case, am I still saying that it a[]has size 5or should I say that it has size 6?

And, if I copy it to an array: int b [4], what happens in this case? What will happen to the integer variable at location 4in a[], does it overwrite \0?

Thank.

+5
source share
3 answers

, , . C , C.

+14

| 0 | 1 | 2 | 3 | 4 | , . 5.

+6

Great explanation of arrays for beginners.

+2
source

All Articles