I find a piece of C++ code in textbook and have some questions.:
int ia[10]; // an integer array with 10 elements
int *ptr = ia; //the address of the first element in array.
int *end = &ia[10]; //
while ( ptr != end ){
std::cout<<*(ptr++)<<" ";
}
std::cout<<std::endl;
Since, the boundary of this array is from 0 to 9, which means that the ia[10]
is out of boundary.
Why it is allowed in C and C++?