#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 = 163.3;
// 구조체 멤버 출력
printf("===학생 정보===\n");
printf("이름 : %s\n", s1.name);
printf("나이 : %d살\n", s1.age);
printf("키 : %.2fcm\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("키 : %.1fcm\n", s2.height);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: