[求助]日期与时间
我想打印出当前日期和时间,请问需要调用什么库函数,该怎样写,谢谢
#include<stdio.h>
#include<time.h>// for strtime()
#include<windows.h>// for system()
void print1(char s[])
{
int i;
for(i=0;s[i];i++)
{
switch(s[i])
{
case '0':printf(" _ ");break;
case '1':printf(" ");break;
case '2':printf(" _ ");break;
case '3':printf(" _ ");break;
case '4':printf(" ");break;
case '5':printf(" _ ");break;
case '6':printf(" _ ");break;
case '7':printf(" _ ");break;
case '8':printf(" _ ");break;
case '9':printf(" _ ");break;
case ':':printf(" ");break;
}
printf(" ");
}
printf("\n");
}
void print2(char s[])
{
int i;
for(i=0;s[i];i++)
{
switch(s[i])
{
case '0':printf("| |");break;
case '1':printf("| ");break;
case '2':printf(" _|");break;
case '3':printf(" _|");break;
case '4':printf("|_|");break;
case '5':printf("|_ ");break;
case '6':printf("|_ ");break;
case '7':printf(" |");break;
case '8':printf("|_|");break;
case '9':printf("|_|");break;
case ':':printf(" . ");break;
}
printf(" ");
}
printf("\n");
}
void print3(char s[])
{
int i;
for(i=0;s[i];i++)
{
switch(s[i])
{
case '0':printf("|_|");break;
case '1':printf("| ");break;
case '2':printf("|_ ");break;
case '3':printf(" _|");break;
case '4':printf(" |");break;
case '5':printf(" _|");break;
case '6':printf("|_|");break;
case '7':printf(" |");break;
case '8':printf("|_|");break;
case '9':printf(" _|");break;
case ':':printf(" . ");break;
}
printf(" ");
}
printf("\n");
}
void main()
{
char now[128];
while(1)
{
system("cls");
_strtime(now);
print1(now);
print2(now);
print3(now);
printf("%s",now);
_sleep(1000);
}
}
[此贴子已经被作者于2007-5-9 9:41:09编辑过]