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
   30   31   32   33   34   35   36   37   38   39   40