인프런 커뮤니티 질문&답변
함수선언 시 foo(ptr)은 되고 foo(*ptr)안되는 이유가 궁금합니다.
작성
·
274
1
강의7-4 1분에서
int *ptr=value;
1. foo(ptr)은 되고 foo(*ptr)이거는 왜안되나요? 위에 변수가 포인터로 선언되었으니 포인터 변수인 후자도 맞지 않나요?
#include<iostream>
using namespace std;
typedef int* pint;
void getsincos(int *ptr)
{
 cout << *ptr << " " << ptr << " " << &ptr << endl;
}
int main()
{
        int value = 5;
        cout << value << " " << &value << endl;
        int *ptr = &value;
        cout << &ptr<< endl;
        getsincos(ptr);
        return 0;
}
2.
cout << *ptr << " " << ptr << " " << &ptr << endl;
이코드중에 ptr은 &value이고 &ptr은 &&value니까 같은 주소일꺼라고 생각했는데 혹시 왜 다른지 알수있나요?





