i would like to ask, why this code doesnt work...
int* funkce(){
    int array[] = {1,2,3,4,5};
    return(array);
  }
int main(){
    int* pp = funkce();
    int* ppk = pp+5;
    for (int *i = pp; i!=ppk; i++){
        cout << (*i) << endl;
    }
    system("PAUSE");
    return(0);
}
This code display:
1
16989655
4651388
- // -
253936048
So the poniter is out of array... But how is possible, that this code with array in Main is ok?
int main(){
    int a[] = {1,2,3,4,5};
    int* pp = a;
    int* ppk = pp+5;
    for (int *i = pp; i!=ppk; i++){
        cout << (*i) << endl;
    }
    system("PAUSE");
    return(0);
}
this code displayed:
1
2
3
4
5
Could you explain to me, why the first one doesnt work? Thank you!
 
     
    