Page 35 - PIC18F4550微處理機C語言設計實務
P. 35
ሔଡ଼ΥႧԊձ C ႧԊ 1
struct class {
int setNo;
char name [8];
int score;
}student1 = {1, "George", 87};
ޟЇ݊j
struct class {
int setNo;
char name [8];
int score;
}student1={1, "George", 87},student2={2, "Hellen", 79};
வᅵఱ܁ѓəɓࡈΤމ class ٙഐۨ࿒dϤۨ࿒̍ўɓࡈᅰۨ࿒ setNo ϓࡰe
ɓࡈ 8 ࡈЗʩଡ଼ٙοЕۨ࿒ name ϓࡰձɓࡈᅰۨ࿒ٙ score ϓࡰf್ܝ܁ѓəՇࡈ
ୌΥ class ഐۨ࿒ٙᜊᅰ student1 ձ student2fԨʱйഗə࿁ٙڋ࠽f
Ңࡁɰ̙˸νɨ܁ѓj
struct { int setNo;
char name [8];
int score;
}student1,student2;
வᅵΝࣛ܁ѓəՇࡈഐᜊᅰdШӚϞഗ༈ഐɓࡈΤ၈dה˸ఱӚ፬جίՉ˼
ή˙˸Ϥഐ܁ѓᜊᅰiৰڢࠠอΎ܁ѓΝഐɓϣf
މə˙کd̙˸Դ͜ typedef Ը່֛ struct Τ၈dԷνj
typedef struct class abc;
˸ܝࠅ܁ѓୌΥ class ഐٙᜊᅰ struct class student1; ࣛdఱ̙˸ٜટɨ abc student1;
у̙fШ݊
typedef struct { int setNo;
char name [8];
int score;
}class;
ۆ class ˾ڌഐΤ၈dʔ݊ഐᜊᅰd̥݊˸ܝࠅ܁ѓഐᜊᅰࣛdఱ̙˸ʔ̀
̋ɪ structj
class student1={1, "George", 87};
25