hello5.c
来自「unix编程实践教程代码。适合初学者」· C语言 代码 · 共 35 行
C
35 行
/* hello5.c * purpose bounce a message back and forth across the screen * compile cc hello5.c -lcurses -o hello5 */#include <curses.h>#define LEFTEDGE 10#define RIGHTEDGE 30#define ROW 10main(){ char message[] = "Hello"; char blank[] = " "; int dir = +1; int pos = LEFTEDGE ; initscr(); clear(); while(1){ move(ROW,pos); addstr( message ); /* draw string */ move(LINES-1,COLS-1); /* park the cursor */ refresh(); /* show string */ sleep(1); move(ROW,pos); /* erase string */ addstr( blank ); pos += dir; /* advance position */ if ( pos >= RIGHTEDGE ) /* check for bounce */ dir = -1; if ( pos <= LEFTEDGE ) dir = +1; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?