본문 바로가기

카테고리 없음

c/c++ 포인터 여러가지 자려형

#include <stdio.h>

 

int main(void)
{
char a = 'A';
char* pA = &a;
int b = 100;
int* pB = &b;
double c = 3.14;
double* pC = &c;

printf("pA크기는 %d byte\n", sizeof(pA));        //64bit는 8byte, 32bit는 4byte
printf("pB크기는 %zd byte\n", sizeof(pB));        //8
printf("pC크기는 %zd byte\n", sizeof(pC));        //8
printf("pA크기는 %zd byte\n", sizeof(*pA));       //1
printf("pB크기는 %zd byte\n", sizeof(*pB));       //4
printf("pC크기는 %zd byte\n", sizeof(*pC));       //8
}