- int* a(포인터 변수 선언), *a(실제 포인팅되어 있는 변수내용), a(주소) - 예제 /* 3.cpp */ #include <iostream> #include <stdlib.h> using std::cout; using std::endl; int main() { int* a; int b=3;
a = &b; // a는 주소값 (&b와 같다.)
cout << sizeof(a) <<endl; //포인터 이므로 4바이트 cout << *a <<endl; //가리키고 있는 값이 없으면 런타임 에러 cout << a <<endl; // a의 주소값 cout << &a <<endl; //a가 포인터 이므로 &a는 이중 포인터의 주소이다. return 0; }