怎样把结构体当函数参数?
程序代码:
#include <stdio.h> #include <stdlib.h> #include <time.h> #define true 1 struct tm StartTime,EndTime; void TimeingJudgment(struct tm); void SetTimeing() { int Startday = 1; int Starthour = 0; int Startmin = 0; int Endday = 1; int Endhour = 0; int Endmin = 0; printf("please input start time \n"); scanf("%d,%d,%d",&Startday,&Starthour,&Startmin); StartTime.tm_mday =Startday; StartTime.tm_hour =Starthour; StartTime.tm_min =Startmin; printf("please input end time \n"); scanf("%d,%d,%d",&Endday,&Endhour,&Endmin); EndTime.tm_mday =Endday; EndTime.tm_hour =Endhour; EndTime.tm_min =Endmin; } void PowerOff() { printf("Interval timing is not\n"); system("pause"); } main() { int second = 0; //临时参数,用来与当前时间比较 SetTimeing(); while(true) //实现了每N秒钟执行一条语句的功能 { time_t time_now = time(0); //调用系统函数,并初始化 struct tm *time_p = localtime(&time_now);//gmtime(&time_now); //获取当前时间 TimeingJudgment(time_p); /* if(time_p->tm_mday < StartTime.tm_mday || time_p->tm_mday > EndTime.tm_mday) { PowerOff(); return; } else if(StartTime.tm_mday == EndTime.tm_mday)//同一天 { if(time_p->tm_hour < StartTime.tm_hour || time_p->tm_hour > EndTime.tm_hour) { PowerOff(); return; } else if(StartTime.tm_hour == EndTime.tm_hour)//同一小时 { if(time_p->tm_min < StartTime.tm_min || time_p->tm_min > EndTime.tm_min) { PowerOff(); return; } } } */ } } void TimeingJudgment(tm *time_Local) { if(time_Local->tm_mday < StartTime.tm_mday || time_Local->tm_mday > EndTime.tm_mday) { PowerOff(); } else if(StartTime.tm_mday == EndTime.tm_mday)//同一天 { if(time_Local->tm_hour < StartTime.tm_hour || time_Local->tm_hour > EndTime.tm_hour) { PowerOff(); } else if(StartTime.tm_hour == EndTime.tm_hour)//同一小时 { if(time_Local->tm_min < StartTime.tm_min || time_Local->tm_min > EndTime.tm_min) { PowerOff(); } } } }
我做了一个函数,会报错,不知道怎么用结构体当函数的参数?