why declaring a pointer is like declaring a dynamic size array ?

i learned that arrays are that of a fixed sized containers
then why doin this , is valid in c++

1
2
3
4
int y =5;
int *x = &y;
x[1] = 54;
cout<<x[0]<<" "<<x[1]<<endl;
It's not valid.

x[1] = 54;
You're trying to access memory that you haven't allocated memory for. Pretty much an array access out of bounds, which results in undefined behaviour.
http://stackoverflow.com/questions/1239938/accessing-an-array-out-of-bounds-gives-no-error-why
Topic archived. No new replies allowed.