첫번째 구조체 예제를 만들어 보자.
#include <stdio.h>
struct bts_t {
int a;
int b;
};
int main() {
struct bts_t bts;
bts.a = 11;
bts.b = 22;
printf("%d, %d\\n", bts.a, bts.b);
return 0;
}
구조체 문법은 아래와 같다. 잘 외워두자.
struct tag_name {
data_type name1;
data_type name2;
}; // (1)
struct tag_name name; // (2)
struct book_t {
char name[128];
int price;
};
struct book_t book1;