liunxc键盘控制实现字符串移动.docVIP

  • 0
  • 0
  • 约1.92千字
  • 约 4页
  • 2017-06-13 发布于北京
  • 举报
通过信号控制屏幕字符串移动。如下图: 输入a,d,w,s表示左,右,上,下。q退出。 要求字符串移动不能出框。 #include stdio.h #include stdlib.h #include unistd.h #include termios.h #include time.h #include string.h #include sys/timeb.h /* 清屏: */ void clear_screen() { system(echo -ne \\033[2J\); } /* 光标定位: y:行坐标,x:列坐标 */ int G_y=2,G_x=2; int setyx(int y,int x) { struct termios tm, tm_old; int fd = STDOUT_FILENO; char c[20]; if(tcgetattr(fd, tm) 0) return -1; tm_old = tm; cfmakeraw(tm); if(tcsetattr(fd, TCSANOW, tm) 0) return -1; fflush(stdout); sprintf(c,echo -ne \\\033[%d;%dH\,y,x); system(c); fflush(stdout); if(tcs

文档评论(0)

1亿VIP精品文档

相关文档