2학년 2학기/c언어
11-3장 구조체 배열
kkkkk1023
2024. 11. 11. 10:41
구조체 배열
: 여러개의 구조체를 하나의 구조체로 만들 수 있다. 배열이기 때문에 인덱싱이 가능하다.
struct student {
int number;
char name[20];
double grade;
};
int main(){
struct student list[100];// 구조체 배열 선언
}
구조체 배열의 초기화
2차원 배열처럼 선언하면 구조체 배열을 초기화 할 수 있다.
struct student {
int number;
char name[10];
double grade;
};
int main(){
struct student list[3] = {
{ 25, "Mun", 3.92 },
{ 24, "Kim", 4.3 },
{ 23, "Tim", 2.9 }
};
}