#include <stdio.h>
// 구조체: 타입이 다른 데이터를 그룹화하는 방법
// 표기: struct
// 별칭사용: typedef struct

typedef struct human_being{
    char name[10];
    int age;
    float salary;
}human_being;

struct human_doing{
    char name[10];
    int age;
    float salary;
};

typedef struct sex_type{
    enum tag_filed{female, male} sex;
    union {
        int children;
        int beard;
    } u;
}sex_type;

sex_type person3, person4;

human_being person1, person2;
struct human_doing  person;


int main() {
    person1.name[0] = 'J';
    person1.name[1] = 'A';
    person1.name[2] = 'N';
    person1.name[3] = 'G';
    printf("human_being name: %c%c%c%c \n", person1.name[0], person1.name[1],person1.name[2],person1.name[3]);

    person.age =10;
    person.salary =300;

    printf("human_doing: %d %5.3f \n", person.age, person.salary);
    printf("Hello world!\n");

    person3.sex=male;
    person3.u.children='C';
    printf("sex_type: %d \n", person3.sex);
    printf("sex_type: %c \n", person3.u.children);
    
    return 0;
}

Embed on website

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