인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

ewsgop7773613's profile image
ewsgop7773613

asked

Let's learn C and C++ at the same time - Doodle Doodle's C/C++

26 - Pointing to an array (array pointer)

왜 포인터를 이용한 배열에서는 12바이트씩 값이 증가 하는 건가요..?

Written on

·

198

0

int main() {

    int arr[3] = { 1,2,3 };

    int (*ptr_arr)[3];

    ptr_arr = &arr;

    for (int i = 0; i < 3; i++) {

        printf("(ptr_arr)[%d] :%d ", i, (ptr_arr)[i]); //12바이트

    }printf("\n");

    for (int i = 0; i < 3; i++) {

        printf("arr[%d] :%d ", i, &arr[i]); //4바이트

    }

}

실행 결과

(ptr_arr)[0] :19922184 (ptr_arr)     [1] :19922196

(ptr_arr)[2] :19922208

arr[0] :19922184 arr[1] :19922188 arr[2] :19922192

C++c

Answer 1

0

동영상 7:00에 설명이 나옵니다

ewsgop7773613's profile image
ewsgop7773613

asked

Ask a question