结构体指针传递后对成员的遍历
#include <stdio.h>#include <stdlib.h>
typedef struct TIMEER
{
unsigned char Year;
unsigned char Month;
unsigned char Day;
unsigned char Hour;
unsigned char Min;
unsigned char Sec;
unsigned char Weak;
}sTime;
sTime CurTime;
void TimeToDisp(sTime* time);
void DISPDAY(unsigned char dat)
{
printf("%d\n",dat);
printf("\n");
}
void TimeToDisp(sTime* time)
{
unsigned char *p_time = time;
unsigned char i;
for(i=0; i<7; i++)
{
DISPDAY(p_time[i]);//请问有没有比这种更好更直观的方法???
}
}
int main()
{
CurTime.Year = 22;
CurTime.Month = 2;
CurTime.Day = 9;
CurTime.Hour = 17;
CurTime.Min = 16;
CurTime.Sec = 22;
CurTime.Weak = 3;
TimeToDisp(&CurTime);
return 0;
}