Why is it when I define a pointer to an array of two int
's, let's say:
int *data;
data = malloc(sizeof(int)*2);
Then insert some values:
*(data) = 22;
*(data+1) = 466;
*(data+2) = 1000;
Even though the array only has the size of 2
, if I print the third element I placed in the vector, it will still show correctly? Is it normal or am I changing memory addresses where I shouldn't be meddling with?