您的位置:首页 > 产品设计 > UI/UE

一个使用 ANSI.SYS Escape Sequences 进行时间显示的例子

2008-07-11 16:12 323 查看
#include <stdio.h>
#include <time.h>
#include <memory.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
time_t t_time;
char *a_time;
char *day;
char *hour;
day=(char*)malloc(15);
hour=(char*)malloc(15);
printf ("/033[2J");

if ( fork () )
exit(0);

while (1)
{
printf("/33[s");
time (&t_time);
a_time=asctime(localtime(&t_time));
bzero(day,15);
bzero(hour,15);
memcpy(day, a_time, 10);
memcpy(hour, a_time+10, 10);
printf("/033[1;45H/033[K +-----------------------+");
printf("/033[2;45H/033[K + net_robber tell you: +");
printf("/033[3;45H/033[K + %s +",day);
printf("/033[4;45H/033[K + %s +",hour);
printf("/033[5;45H/033[K +-----------------------+");
printf("/33[u");
fflush(stdout);
sleep(1);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  include
相关文章推荐