๋ฐ์ํ
๊ตฌ์กฐ์ฒด
์ฌ๋ฌ ์ข ๋ฅ์ ์๋ฃํ์ ํ๊บผ๋ฒ์ ์ ์ฅํ๋ ๋ฐฉ๋ฒ
struct student {
char name[20+1];
int year;
float score;
};
struct(๊ตฌ์กฐ์ฒด) ์ข ๋ฅ
- point
- date
- complex
- rect
- employee
struct(๊ตฌ์กฐ์ฒด) ๋ณ์ ์ ์ธ
1.
struct student {
int number;
char name[10];
double grade;
};
struct student s = {24, "kim", 4.3};
2.
struct student {
int number;
char name[10];
double grade;
} s = {24, "kim", 4.3};
//ํํ
s.number
s.name
s.grade
//์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ํํํจ
//๋ง์ฝ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ํ๊ณ ์ถ๋ค๋ฉด,
3.
struct student {
int number;
char name[10];
double grade;
};
struct student s;
s.number = 24;
strcpy(s.name, "kim");
s.grade = 4.3;
//๊ณผ ๊ฐ์ด ๋ฐ๋ก ํ๋ ํ๋ ์ ์ํด์ค์ผ ํจ
์ค์!
- ๊ตฌ์กฐ์ฒด ๋ณ์์ ๋์ ๊ณผ ๋น๊ต!! → ์ง์ ๋น๊ตํด์ค์ผ ํจ / ๊ทธ๋ฅ ํต์งธ๋ก ๊ฐ๋ค๊ณ ํ์ธํ ์ ์์
๊ตฌ์กฐ์ฒด ๋ฐฐ์ด
- ๊ตฌ์กฐ์ฒด๋ฅผ ํฌ์ธํฐ ๋ฐฐ์ด๊ณผ ๊ฐ์ด ๋ง๋ค์ด์ ์ฌ์ฉํ ์ ์์
๊ตฌ์กฐ์ฒด ํฌ์ธํฐ
- ๊ตฌ์กฐ์ฒด๋ฅผ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ
- ํฌ์ธํฐ๋ฅผ ๋ฉค๋ฒ๋ก ๊ฐ์ง๋ ๊ตฌ์กฐ์ฒด
๊ตฌ์กฐ์ฒด์ ํจ์
- ๊ตฌ์กฐ์ฒด๋ฅผ ํจ์์ ์ธ์๋ก ์ ๋ฌํ๋ ๊ฒฝ์ฐ
- ํจ์์์ ๊ตฌ์กฐ์ฒด(๋ณต์ฌ๋ณธ)์ ๋ฐํํ๋ ๊ฒฝ์ฐ
- ๊ตฌ์กฐ์ฒด์ ์ฃผ์๋ฅผ ํจ์์ ์ธ์๋ก ์ ๋ฌํ๋ ๊ฒฝ์ฐ
๋ฐ์ํ