달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

간단하게 말해 pointer형 변수를 참조하겠다는 뜻이다.

아래 코드를 참조하면 이해가 될 것이다.


int a = 5;

int* b = &a;

printf("%d, %d", a, *b); //5, 5로 출력

int*& c = b; //포인터 변수 b를 참조

printf("%d, %d, %d", a, *b, c); //5, 5, 5로 출력

c=10;

printf("%d, %d, %d", a, *b, c); //10, 10, 10로 출력

int d = 3;

b = &d;

printf('%d, %d, %d", a, *b, c); //10, 3, 3로 출력 


 char *str = "Hello";


char *ptr = str;
char *&rptr = str;
char *world = "World";
ptr = world;

printf(str); // Hello 출력


rptr = world;

printf(str); //World 출력



Posted by 생짜
|