该程序显示字符左右移动

 

/**
* curses3.c
*/
#include
<stdio.h>
#include
<curses.h>
#include
<sys/ioctl.h>
#include
<signal.h>
void restandend();
int main(int ac,char *av[])
{
struct winsize wbuf;
int rows,cols;
int dir=+3,pos=0;
//signal(SIGINT,restandend);
if(ioctl(0,TIOCGWINSZ,&wbuf)!=-1)
{
        rows
=wbuf.ws_row;
        cols
=wbuf.ws_col;
}
rows
=10;
//printf("row=%d col=%d\n",rows,cols);
initscr();
while(1)
{
        move(rows,pos);
        addstr(
"cartoon");
        
if(pos>(cols-9&& dir==+3)
                dir
=-3;
        
if(pos<=0 && dir==-3)
                dir
=+3;
        sleep(
1);
        refresh();
        move(rows,pos);
        addstr(
"       ");
        pos
+=dir;
}
standend();
return 0;
}
void restandend()
{
move(
0,0);
addstr(
"exit");
refresh();
standend();
exit(
1);
}

 

相关文章:

  • 2022-12-23
  • 2021-07-09
  • 2021-09-29
  • 2021-10-04
  • 2022-12-23
  • 2021-06-14
  • 2021-05-07
  • 2021-11-11
猜你喜欢
  • 2021-10-03
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-09-07
相关资源
相似解决方案