use gcc rotate.c -lcurses -o xxx when compiling~
===================================================================
/*
* rotate.c
*/
#include
#define ROW 10
#define COL 20
void show(char *);
int
main(void)
{
char *sign_1 = "Initializing |";
char *sign_2 = "Initializing /";
char *sign_3 = "Initializing -";
char *sign_4 = "Initializing \\";
initscr(); /* turn on curses */
clear(); /* clear screen for drawing */
while(1) { /* in a loop */
show(sign_1); /* draw sign_1 */
show(sign_2); /* draw sign_2 */
show(sign_3); /* draw sign_3 */
show(sign_4); /* draw sign_4 */
}
endwin(); /* reset the tty etc */
}
void show(char *sign)
{
/*
* draw a sign and wait 1 second
*/
move(ROW, COL); /* move cursor for drawing */
waddstr(stdscr, "Hello, world!");
move(ROW+1, COL);
addstr(sign); /* add a string */
move(LINES+1, COL); /* move cursor */
refresh(); /* refresh window */
usleep(1000*1000); /* sleep */
}
阅读(814) | 评论(0) | 转发(0) |