🔑 key word : struct array
union
enum
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
struct student { //구조체 정의
unsigned int sid; //4 byte
char name[20]; //20
float grade; //4
};
void showStudentInfo(struct student _s) { //구조체 출력함수
printf("%d : %s --> %.2f\n", _s.sid, _s.name, _s.grade);
}
int main()
{
////////////// 구조체 배열 ////////////////
struct student st_db[3] = { //구조체 초기화
{1,"kim",3.8},
{2,"lee",3.9},
{3,"park",4.0}
};
printf("%d\n", sizeof(st_db)/sizeof(struct student));//구조체 배열의 갯수 (84/28)
for (int i = 0; i < 3; i++) { //구조체 출력
showStudentInfo(st_db[i]);
}
return 0;
}