내가 왜이 코드 나던 작업을 부탁드립니다 표시 ...C++ 배열을 반환하고
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);
}
이 코드 표시 :
1
16989655
4651388
- // -
253936048
그래서 poniter 배열 벗어 .. 하지만 Main에 배열이있는이 코드는 괜찮습니까?
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);
}
이 코드 표시 :
1
2
3
4
5
당신이 나에게 왜 첫 번째 나던 작품을 설명 할 수 있을까요? 감사합니다.
http://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope – chris