有curses怎么不用呢?
#include <stdio.h>
#include <string.h>
#include <curses.h>
#include <unistd.h>
#define LEFT 1
#define RIGHT 30 * 2
#define ROW 40 / 2
int main(void)
{
char * msg = "<Hello world>" ;
char * blank = " " ;
int dir = 1 ;
int curpos = LEFT ;
int slen = strlen(msg) ;
initscr() ;
clear() ;
while(1) {
move(ROW , LEFT -1) ;
addch('|') ;
move(ROW , RIGHT + slen ) ;
addch('|') ;
move(ROW , curpos) ;
addstr(msg) ;
move(LINES -1 , COLS -1) ;
refresh() ;
usleep(0.3 * 1e6 ) ;
move(ROW , curpos) ;
addstr(blank) ;
curpos += dir ;
if (curpos == RIGHT)
dir = -1 ;
if (curpos == LEFT)
dir = 1 ;
}
return 0 ;
}