Page 33 - PIC18F4550微處理機C語言設計實務
P. 33

૵ሔଡ଼ΥႧԊձ C ႧԊ 1




                       ܸᅺהܸٙЗѧʘʫ࢙הᎷπٙ༟ࣘۨ࿒  * ܸᅺΤ၈ ;

                 Էνj

                        int  *ipointer;  // ੭ୌ໮ᅰ࠽π׳Зѧܸٙᅺ ipointer
                        char *cpointer;  //  8 Зʩ༟ࣘʫ࢙π׳Зѧܸٙᅺ cpointer

                       ܁ѓۨ࿒ʑঐٝ༸ܸᅺӊ̋ 1 ࣛdࠅ༪ཀεˇЗʩଡ଼f

                       ίਂ܁ѓމܸᅺࣛdܸᅺΤ၈ۃࠦࠅ̋ * ໮fࠅ຾ܸᅺπ՟הܸٙЗѧʘʫ࢙ࣛd

                 ίܸᅺۃࠦࠅ̋ * ໮f

                 Էνj

                   unsigned char Array[] = {0,1,2,3};
                   unsigned char *cpointer;
                   cpointer = &Array[0];    // ਗ਼ cpointer ܸᅺܸΣ Array[0] ٙЗѧ
                   *cpointer = 1;          // ਗ਼ cpointer ܸᅺܸΣٙЗѧ€ɰఱ݊ Array[0]
                   ࡌҷމ 1dੂБഐҼʘܝ Array[] ৬ΐٙʫ࢙ਗ਼ᜊϓ {1,1,2,3}

                       ࠅ຾༶ၑאܸݼ€assign˸՟੻ܸᅺהܸٙЗѧࣛdܸᅺΤ၈ۃࠦʔ̋ * ໮f

                 Էνj


                 ટᚃɪࠦٙ܁ѓd߰ࠅࡌҷ Array[1] ٙʫ࢙d˙جνɨj

                   cpointer = cpointer+1;
                   *cpointer = 5;


                       Ϊމ cpointer ݊܁ѓމ unsigned char ܸٙᅺdה˸ +1 ڌͪЗѧᄣ̋ɓࡈ Byted
                 ΪϤ +1 ʘܝܸ݊Ց Array[1] ٙЗѧf

                       ੂБഐҼʘܝ Array[] ৬ΐٙʫ࢙ਗ਼ᜊϓ {1,5,2,3}f

                       Ңࡁ̙˸Դ͜ & ༶ၑɿ՟̈ᜊᅰٙЗѧ࠽Ԩܸ֛ഗܸᅺdԷνj


                   int abc = 0x3d ;   // ܁ѓɓࡈ዆ᅰᜊᅰ abcdՉʫ࢙݊ 0x3d
                   int *iptr = &abc ; // ܁ѓɓࡈܸᅺ *iptr ܸΣ዆ᅰᜊᅰ abc ٙЗѧ
                   iptr = iptr+1;     // ܸᅺ *iptr ܸΣɨɓࡈЗѧ€iptr ʫ࢙̋ 2dΪމ݊዆ᅰ
                   *iptr = *iptr + 1; // ܸᅺ *iptr הܸٙাኳ᜗ʫ࢙̋ 1diptr ʫ࢙Ӛᜊ

                       ܸᅺٙࠠᓃ̌ঐ̙݊˸஗༶ၑ˸՟੻הࠅٙЗѧdৰəܸ֛༶ၑ =d՟ѧ༶ၑɿ

                 & ၾ՟࠽༶ၑɿ * ̮dᒔϞ̋ +eಯ –e჈ᄣ ++e჈ಯ ––e޴̋ܝܸ֛ += ၾ޴ಯܝ
                 ܸ֛ –= ഃ༶ၑɿ̙˸Դ͜f




                                                                                                             23
   28   29   30   31   32   33   34   35   36   37   38