首先,请看以下程序段:
//声明变量部分
volatile uchar MM[5];
struct DT
{
uint Day;
uchar Day_Number[5];
uint Hour;
uchar Hour_Number[5];
uint Min;
uchar Min_Number[5];
uint Sec;
uchar Sec_Number[5];
uint MS;
uint MS_Number[5];
};
struct VT
{
uchar progress;
uchar stage;
uchar Recharge_No;
struct DT Time0;
struct DT Time1;
struct DT Time2;
struct DT Time3;
struct DT Time4;
};
volatile struct VT F_VT, K_VT;
//声明函数部分
void Num_Dismantle(uint var, uchar Number[])
{
Number[0] = var % 10;
Number[1] = (var%100) / 10;
Number[2] = (var%1000) / 100;
Number[3] = (var%10000) / 1000;
Number[4] = var / 10000;
}
//主程序部分
void main()
{
F_VT.Time1.Hour = 18;
Num_Dismantle(F_VT.Time1.Hour, MM);
Num_Dismantle(F_VT.Time1.Hour, F_VT.Time1.Hour_Number);
Num_Dismantle(F_VT.Time1.Hour, & (F_VT.Time1.Hour_Number));
}
运行结过,Num_Dismantle函数的第一次调用是没有问题的,结果是:MM[0]为8,MM[1]为1。可第二个和第三个就都不对了,肯定指针这里调用的有问题,恳请指正! |