✅ 목표 (Goal)

구조체 내의 포인터 변수에 접근해보자.

✅ 구조체 내의 포인터 변수가 있다면 어떻게 접근하나?

typedef struct _abc_t {
	int a;
	int *pa;
} abc_t;

abc_t abc;
#include <stdio.h>

int small_font[5] = { 11, 22, 33, 44 };
int big_font[5] = { 55, 66, 77, 88 };

typedef struct _lcd_t {
    int x;
    int y;
    int* font;  //font_t* font;
} lcd_t;

print_font(lcd_t* lcd) {
    for (int i = 0; i < 4; i++) {
        printf("%d,", lcd->font[i]);
    }
}

int main() {

    lcd_t lcd;

    lcd.x = 3;
    lcd.y = 5;

    lcd.font = small_font;
    print_font(&lcd);

    return 0;
}

Untitled

▼ 구조체 내부에 포인터 사용하기

https://mndd.tistory.com/42