When you go past the end of allocated memory, you are actually accessing memory of some other object (or memory that is free right now, but that could change later). So, it will cause you problems. Especially if you’ll try to write something to it.
More Related Contents:
- What is the difference between '.' and '->' when used in array? [closed]
- Why is sizeof giving incorrect number of bytes in C++?
- Passing a 2D array to a C++ function
- determine size of array if passed to function
- May I treat a 2D array as a contiguous 1D array?
- Why does cout print char arrays differently from other arrays?
- C++ pass an array by reference
- Address of an array
- How does delete[] know it’s an array?
- May I take the address of the one-past-the-end element of an array? [duplicate]
- C++ correct way to return pointer to array from function
- Store an int in a char array?
- Pointer-to-pointer dynamic two-dimensional array
- How to get the real and total length of char * (char array)?
- Pointer interconvertibility vs having the same address
- Are non dereferenced iterators past the “one past-the-end” iterator of an array undefined behavior?
- can’t modify char* – Memory access violation
- Pointer to array with const qualifier in C & C++
- Why are `&array` and `array` pointing to the same address?
- How do I create an array of pointers?
- Pointer to array of unspecified size “(*p)[]” illegal in C++ but legal in C
- array decay to pointer and overload resolution
- array of pointers as function parameter
- Function returning array but main showing garbage [duplicate]
- Difference between passing array, fixed-sized array and base address of array as a function parameter
- how do arrays work internally in c/c++
- difference between pointer to an array and pointer to the first element of an array
- How can a char pointer be initialized with a string (Array of characters) but an int pointer not with an array of integer? [duplicate]
- Polymorphism & Pointers to arrays [duplicate]
- int *array = new int[n]; what is this function actually doing?