c語言定義結(jié)構(gòu)體指針
{
typedef struct
{
u8 KeyCurrentIndex;//當(dāng)前狀態(tài)索引號
u8 KeyEnterState;//按下【enter】鍵時轉(zhuǎn)向的索引號
u8 KeyCancelState;//按下【cancel】鍵時轉(zhuǎn)向的索引號
u8 KeyUpState;//按下【up】鍵時轉(zhuǎn)向的索引號
u8 KeyDownState;//按下【down】鍵時轉(zhuǎn)向的索引號
void (*CurrentOperate)(); //當(dāng)前狀態(tài)下執(zhí)行的功能操作
}KbdTabStruct;
const KbdTabStruct KBD[]=
{
{0,1,2,3,4,(*main)},
{6,7,8,9,10,11},
{0,1,2,3,4,5},
{0,1,2,3,4,5},
};
const KbdTabStruct KBD1=
{
20,27,38,39,40,51,
};
KbdTabStruct *ptr=&KBD[1];//定義指向結(jié)構(gòu)體的指針變量 ptr 并賦初值KBD
KbdTabStruct *pr=&KBD1;//定義指向結(jié)構(gòu)體的指針變量 pr 賦初值KBD1
printf("%d",KBD[0].KeyEnterState);//應(yīng)是1
printf("%d",KBD[1].KeyCurrentIndex);//6
printf("%d",KBD[1].KeyDownState);//10
printf("%d",ptr->KeyDownState);//10
printf("%d",(*ptr).KeyDownState);//10
printf("%d",(*pr).KeyDownState);//40
}
評論