该程序显示为每行变换背景颜色

 

#include<stdio.h>
#include
<curses.h>
#include
<sys/ioctl.h>
//#define LINES 22
int main(int ac,char *av[])
{
int rows=0;
int cols=10;
int LINES;
struct winsize wbuf;
if(ioctl(0,TIOCGWINSZ,&wbuf)!=-1)
{
        
//printf("%d\n",wbuf.ws_row);
        
//getch();
        LINES=wbuf.ws_row-1;
}
//printf("LINES:%d\n",LINES);
//getch();
initscr();
while((LINES-rows)>0)
{
        move(rows,cols);
        
if(rows%2==0)
                standout(); 
//反显背景颜色
        addstr("hello,curses!");
        
if(rows%2==0)
                standend();
        refresh();
        rows
++;
        sleep(
1);
}
move(LINES
+1,0);
getch();
endwin();
return 0;
}

 

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-12-23
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2021-06-30
  • 2021-10-31
  • 2021-06-06
  • 2022-12-23
  • 2021-11-21
  • 2021-10-25
  • 2022-02-14
相关资源
相似解决方案