又学curses库
#include
#include
static int finish(int sig);
WINDOW *scrwin, *boxwin;
int main()
{
int i;
char ch;
initscr();
cbreak();
noecho();
nonl();
scrwin=newwin(10,40,LINES/2-6,COLS/2-25);
boxwin=newwin(12,42,LINES/2-7,COLS/2-26);
scrollok(scrwin,1);
box(boxwin, '|', '-');
refresh();
wrefresh(boxwin);
signal(SIGINT, finish);
signal(SIGQUIT, finish);
for(i=0;;i++)
{
if(i%20==0)
sleep(1);
wprintw(scrwin, "the string is %d\n",i%9);
wrefresh(scrwin);
}
}
int finish(int sig)
{
endwin();
return 0;
}
gcc -Wall -g -o a a.c
再补上一笔
#include
#include
#include
static int finish(int sig);
WINDOW *scrwin, *boxwin;
int main()
{
FILE *fp;
int i,j;
char ch;
fp=fopen("/root/aaa.txt","w+");
initscr();
cbreak();
noecho();
nonl();
scrwin=newwin(10,40,LINES/2-6,COLS/2-25);
boxwin=newwin(12,42,LINES/2-7,COLS/2-26);
scrollok(scrwin,1);
box(boxwin, '|', '-');
refresh();
wrefresh(boxwin);
signal(SIGINT, finish);
signal(SIGQUIT, finish);
for(i=0;;i++)
{
if(i%20==0)
if(getchar()=='q')
return 0;
sleep(1);
wprintw(scrwin, "the string is %d\n",j=i%9);
fprintf(fp,"the string is %d\n",j);
wrefresh(scrwin);
}
fclose(fp);
return 0;
}
int finish(int sig)
{
endwin();
return 0;
}
阅读(2685) | 评论(0) | 转发(0) |