以下两个函数值功能如何结合起来?
[code=C/C++][/
//显示日期时间函数
#include <stdio.h>
#include <string.h>
#include <time.h>
int Show(void)
{
char str[100];
time_t t;
struct tm *lt;
t = time(NULL);
lt = localtime(&t);
strftime(str,100,"%Y-%m-%d %H:%M:%S ",lt);
printf("当前日期及时间是:\n%s\n",str);
getch();
return 0;
}
main()
{
Show();
}
//显示星期几函数
#include <time.h>
#include <stdio.h>
enum {SUN=0, MON, TUE, WED, THUR, FRI, SAT};
void ShowTime(void) //显示当前星期的函数
{
struct tm *st;
time_t t;
time(&t);
st=localtime(&t);
printf("Today is ");
switch (st->tm_wday)
{
case SUN: printf("Sunday\n"); break;
case MON: printf("Monday\n"); break;
case TUE: printf("Tuesday\n"); break;
case WED: printf("Wednesday\n"); break;
case THUR: printf("Thursday\n"); break;
case FRI: printf(" Friday\n"); break;
case SAT: printf("Saturday\n"); break;
default: break;
}
}
int main() //主函数
{
ShowTime();
}
]