본문 바로가기
C언어/포인터

[C언어] 포인터의 연산

by bigpicture 2022. 3. 31.
반응형

int 형 포인터에 1을 더하면, 값이 4 증가한다. 크기만큼 증가하는 것이다. double 이라면 8이 증가할 것이다. 

아래는 예시이다. 

#include <stdio.h>

int main(void)
{

    int num=3;

    int *p_num=&num;
    
    printf("%p\n",p_num);
    printf("%p\n",p_num+1);
    printf("%p\n",p_num+2);
    printf("%p\n",p_num+3);   
}

 

반응형

댓글