The behaviour of p[10]
is undefined as the array has only 10 elements and the first element is at position 0. You can access p[0]
(which is the same as *p
) to p[9]
inclusive.
In other words, arrays in C++ are zero-based. Cf. Fortran, for example, where they are one-based.
solved Can someone tell me what is wrong with this statement? [closed]