Suppose I have 2D array such as:
A[3][10]; Does it mean it is an array of 3 pointers? (from which everyone points to 1 of 10 elements)
So A is a pointer which points to 1 of 3 pointers?
No.
It means it's an array of 3 arrays, where each of these is an array with 10 elements.
If it helps, you can think of it as one big 1D array of 30 elements with compiler support that allows you to use 2D indexing (the compiler performs the necessary calculations to turn your indexes into a flat index). In fact, this is actually how it is implemented.
No, it is not an array of 3 pointers. Look at the memory representation:
A[3][10] = |_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_| ^ ^ px px+4 That is, A is an array of 3 arrays which contains 10 elements each. These three arrays are contiguous in memory. That is, the element after A[0][9] is A[1][0].
And of course, as chris said, don't confuse arrays with pointers.
A[0][10] is the same as A[1][0] as the first expression has undefined behaviour. You could legitimately say 'the element after A[0][9] is A[1][0]' and not even I could take exception to that.A[0][10] boils down to *(*A+10) which is well inside the given space. So does it remain undefined? :)*(*A+10) rather than **(A+10), for one thing (because **(A+10) is accessing wildly outside the array). But since *A or A[0] is of type 'pointer to array of 10 int', any use of subscript 10 is accessing out of bounds and should be avoided. While I don't know of a system where there'd be a problem, accessing an array element that is out of bounds leads to undefined behaviour and should not be taught.
realloc()in C) for another.