#include <stdio.h>

int main() {
    // 구조체 : 여러가지 자료형을 한번에 저장하는 자료형
    /* 구조체 정의 
    struct 구조체이름 {
        자료형1 변수이름1;
        자료형2 변수이름2;
    };
    */
    struct Student {
        char *name;
        int age;
        float height;
    };

    // 구조체 변수 만들기
    // struct 구조체이름 변수이름
    struct Student s1; // 자료형 struct Student, 변수이름 s1

    // 구조체 멤버 저장
    // 변수이름.멤버이름 = 값;
    s1.name = "임이랑";
    s1.age = 12;
    s1.height = 146.5;

    // 구조체 멤버 출력
    printf("===학생 정보===\n");
    printf("이름 : %s\n", s1.name);
    printf("나이 : %d\n", s1.age);
    printf("키 : %.1f\n", s1.height);

    struct Student s2;
    s2.name = "김도현";
    s2.age = 14;
    s2.height = 158.2;

    printf("===학생 정보===\n");
    printf("이름 : %s\n", s2.name);
    printf("나이 : %d\n", s2.age);
    printf("키 : %.1f\n", s2.height);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: