You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
사용하는 모든 변수는 메모리의 특정 위치에 저장되는데, 그 위치를 나타내는 메모리의 주소를 포인터라고 한다!
/* 포인터 변수의 크기는 일반적으로 메모리 주소의 크기인 2바이트 *//* 포인터 변수의 타입은 해당 포인터가 가리키는 데이이터 길이를 뜻한다고 볼 수 있다. *//* 그러니까 액세스 범위를 뜻한다고도 할 수 있다. */char*ptr_c;
short*ptr_s;
int*ptr_i;
$ gcc 2-11.c -o 2-11.out && ./2-11.out
>
2-11.c: In function‘main’:
2-11.c:15:35: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char **’ [-Wformat=]
printf("\n ptrArray[0] addr: %u", &ptrArray[0]);~^ ~~~~~~~~~~~~
2-11.c:16:34: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char *’ [-Wformat=]
printf("\n ptrArray[0] has: %u", ptrArray[0]);~^ ~~~~~~~~~~~
%s
2-11.c:20:35: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char **’ [-Wformat=]
printf("\n ptrArray[1] addr: %u", &ptrArray[1]);~^ ~~~~~~~~~~~~
2-11.c:21:34: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char *’ [-Wformat=]
printf("\n ptrArray[1] has: %u", ptrArray[1]);~^ ~~~~~~~~~~~
%s
2-11.c:25:30: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char ***’ [-Wformat=]
printf("\n ptrptr addr: %u", &ptrptr);~^ ~~~~~~~
2-11.c:26:29: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char **’ [-Wformat=]
printf("\n ptrptr has: %u", ptrptr);~^
2-11.c:27:33: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char *’ [-Wformat=]
printf("\n ptrptr 1st val: %u", *ptrptr);~^ ~~~~~~~
%s
ptrArray[0] addr: 312596688
ptrArray[0] has: 20814036
ptrArray[0] val: K
ptrArray[0] val_str: Korea
ptrArray[1] addr: 312596696
ptrArray[1] has: 20814042
ptrArray[1] val: S
ptrArray[1] val_str: Korea
ptrptr addr: 312596680
ptrptr has: 312596688
ptrptr 1st val: 20814036
ptrptr 2nd val: K
ptrptr 2nd val_str: Korea