- 论坛徽章:
- 0
|
我在sco 5.0.6下编译
我想显示时间变动的输出,代码如下
是不是需要用fork()来实现
- #include<curses.h>;
- #include<sys/timeb.h>;
- #include<time.h>;
- #define ESCAPE 27
- init_curses()
- {
- initscr();
- start_color();
- init_pair(1,COLOR_WHITE,COLOR_BLUE); /** 蓝底白字 **/
- curs_set(0);
- noecho();
- keypad(stdscr,TRUE);
- }
- main ()
- {
- int key;
- char str[20];
- struct tm *t_nowtime;
- time_t lt;
- WINDOW * bom_win,* scoll_win;
- lt=time(NULL);
- t_nowtime=localtime(<);
- strftime(str,15,"%X",t_nowtime);
- init_curses();
- bkgd(COLOR_PAIR(1));
- box(stdscr,'┃','━');
- /*** 画底部方框 ***/
- bom_win=subwin(stdscr,3,80,22,0);
- box(bom_win,ACS_VLINE,ACS_HLINE);
- scoll_win=subwin(bom_win,1,79,23,1);
- touchwin(scoll_win);
- wprintw(scoll_win,str);
- wprintw(scoll_win,"%c",ACS_VLINE);
- refresh();
- do
- {
- key=getch();
- touchwin(scoll_win);
- werase(scoll_win);
- wrefresh(scoll_win);
- lt=time(NULL);
- t_nowtime=localtime(<);
- strftime(str,15,"%X",t_nowtime);
- wprintw(scoll_win,str);
- wrefresh(scoll_win);
- touchwin(stdscr);
- refresh();
- } while(key!=ESCAPE);
- endwin();
- return(0);
- }
复制代码
先谢谢了! |
|