linux 画图编程测试二

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

#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;
}
原文地址:https://www.cnblogs.com/ringwang/p/1429901.html