I came across something rather strange and I couldn't find anything reasonable.
I wrote a function like this that returns an int pointer like this: 

```
int* arr()  
{  
  int array[3]={1,2,3};  
  return array;  
}

```

now in the main, I declared an int pointer like k:

```
int*k=arr();

```

it worked perfectly OK,but here is the strange thing, I could only use one of the blocks, k[0] or k[1] or k[3] and it would print the correct corresponding number but when wanted to use it in a for like this only the first one would print correctly:

```
for(int i=0;i<3;i++)
{
  cout<<k[i]<<endl;
}

```

for k[0],the printed value was correct but for the others it was something odd.
I want to know if I didn't used the pointers correct why could I access each block?