-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
질문드립니다.
20.05.18 15:28 작성 조회수 124
2
안녕하세요
강의 잘 듣고 있습니다. 질문 있습니다.
int* const ptr 과 int const* ptr은 별의 위치가 다른데 동일한 포인터 입니까?
답변을 작성해보세요.
2
![Hello Yeo님의 프로필](https://cdn.inflearn.com/public/main/profile/default_profile.png?w=48)
Hello Yeo
2020.05.18
둘은 다릅니다.
int * const ptr 은
constant pointer to integer 입니다. (initializer 필요, ptr의 값 바꿀 수 없음)
int const* ptr 은
pointer to constant integer 입니다. (ptr이 가리키는 값 바꿀 수 없음)
다음은 같습니다.
int const *ptr; //constant pointer to integer
const int *ptr; //constant pointer to integer
https://www.geeksforgeeks.org/difference-between-const-int-const-int-const-and-int-const/
참고하시면 도움이 되실 것 같습니다. 저도 헷갈렸는데 덕분에 다시 봤네요.
답변 1