구조체 내의 포인터 변수에 접근해보자.
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;
}
▼ 구조체 내부에 포인터 사용하기