改编了下,请笑纳。
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <conio.h>
int main()
{
system("title 哈哈哈,这里是C语言的CMD窗!!");
system("pause");
system("cls");
system("echo 哈哈哈,欢迎来到C语言编程的CMD窗口。");
system("pause");
system("cls");
printf("下面,系统将会输出当前时间:\n");
system("pause");
system("cls");
struct tm*m;
time_t secs;
time(&secs);
time_t now;
time(&now);
m=localtime(&secs);
char str[10];
if(!(strncmp(ctime(&now),"Sun",3)))
strcpy(str,"日");
if(!(strncmp(ctime(&now),"Mon",3)))
strcpy(str,"一");
if(!(strncmp(ctime(&now),"Tue",3)))
strcpy(str,"二");
if(!(strncmp(ctime(&now),"Wed",3)))
strcpy(str,"三");
if(!(strncmp(ctime(&now),"Thu",3)))
strcpy(str,"四");
if(!(strncmp(ctime(&now),"Fri",3)))
strcpy(str,"五");
if(!(strncmp(ctime(&now),"Sat",3)))
strcpy(str,"六");
system("mode con: cols=43 lines=1");
HWND handle=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
HWND hWnd=GetForegroundWindow();
system("color 1b");
while(1)
{
time(&secs);
m=localtime(&secs);
printf("现在时间: ");
printf("%d年%d月%d日 星期%s ",m->tm_year+1900,m->tm_mon+1,m->tm_mday,str);
printf("%d时%d分%d秒",m->tm_hour,m->tm_min,m->tm_sec);
if(kbhit())
exit(0);
Sleep(1000);
system("cls");
}
return 0;
}[/mw_shl_code] |