이중 포인터 초간단 예제

  • Post author:
  • Post category:C
  • Post comments:0 Comments

이중포인터의 함수 인자 전달 과정을 보이는 예제입니다.

#include <stdio.h>                                                                                                                 
#include <stdlib.h>

void func(int **a);

int main(void)
{
    int *x; 

    func(&x);

    printf("test : %d\n", *x);

    return 0;

}

void func(int **a)
{
    *a = malloc(sizeof(int));
    **a = 3;

    printf("a = %d\n", **a);

}

 

Leave a Reply