Page 32 - PIC18F4550微處理機C語言設計實務
P. 32
PIC18F4550 ฆஈଣዚ C ႧԊணࠇྼਕ
Էνj
int score [3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
˸Ϥᗳપdɰ̙˸܁ѓɧၪ৬ΐd̥݊ܘˇϞዚึԴ͜Ցf
■ 字串(字元陣列)
ί C ႧԊʕdοЕఱ݊͟οʩהଡ଼ϓٙ৬ΐdԨί௰ܝ̋ɪɓࡈ٤nullοʩ
'\0'd܁ѓοЕࣛdஷ੬ٜટഗοЕڋʫ࢙d̙˸ɓࡈο͎ɓࡈο່͎֛ٙdӊࡈο
͎˸ఊˏՒৎԸd್ܝ˸ஸʱකd௰ܝࠅ̋ɓࡈ٤οʩd್ܝ͜ɽܼՒৎԸf
א݊͜ᕐˏਗ਼ࡈοЕΐ̈dʔ̀̋٤οʩdᇜᙇኜึІБ̋ɪ̘dɰʔ̀͜ɽܼ
fί܁ѓοʩ৬ΐࣛdʔ̀ί৬ΐୌ [ ] ʕഗڗܓiԷνɨࠦٙ܁ѓ݊Νٙj
char abc[]={'h', 'e', 'l', 'l', 'o', '\0'};
char abc[]="hello";
܁ѓʘܝఱ̙˸ٜટԴ͜ abc Ը˾ڌ༈οЕf
1-3-4 指標(Pointer)
ίଡ଼ΥႧԊʕdϞהፗٙගટ֛ѧd݊˸ݔɓࡈᅲπኜЪЗѧܸᅺd˸̴Ըܸ
ΣݔাኳאᅲπኜٙЗѧਂ༟ࣘٙπ՟fᗫᒟίவࡈගટ֛ѧܸٙᅺᅲπኜ̙˸
ཀ༶ၑԷνᄣאಯϾ՟הซࠅπ՟ٙɓӻΐЗѧf
வ၇ගટ֛ѧٙዚՓdఱ݊ί C ႧԊʕܸٙᅺd̙ܸΣɓࡈাኳЗѧd࿁༈া
ኳЗѧЪගટЪf
ᜊᅰఱ݊ɓࡈՈϞΤ၈ٙাኳ٤ගdɓࡈᜊᅰ̍ў༟ࣘۨ࿒˸ᆽ֛াኳ٤ග
ɽʃeᜊᅰ࠽˸່֛Ꮇπٙʫ࢙࠽ձᜊᅰΤ၈d˸˾ڌྼყৣໄٙᎷπ٤ගЗѧf
್ܝ̙ᜊᅰΤ၈Ը՟༈ᜊᅰהܸٙЗѧʫ࢙f
ν؈ࠅٝ༸ݔࡈᜊᅰπίাኳٙЗѧʔ݊ʫ࢙d̙˸ίᜊᅰٙۃࠦ̋ɪ &
ୌ༶ၑɿd& ݊՟ѧ༶ၑɿAddress-of operatord̙˸՟̈ᜊᅰٙাኳЗѧf
Էνj
unsigned char Var;
unsigned int VarAddr;
VarAddr = &Var; // VarAddr ٙʫ࢙ਗ਼݊ Var ίাኳٙЗѧdϾʔ݊ʫ࢙ܸᅺ
ٙ܁ѓႧجf
22