liunx 画图程序测试一
该程序测试时是向屏幕写入字符串,比较简单
编译时如果说函数找不到请带上 -lcurses 或 -lncurses 参数
/**
* curses1.c
* 编译时最好带上 -lcurses 参数
*/
#include<stdio.h>
#include<sys/ioctl.h>
#include<curses.h>
int main(int ac,char *av[])
{
struct winsize wbuf;
int rows;
if(ioctl(0,TIOCGWINSZ,&wbuf)!=-1) //获取屏幕的大小方法
{
printf("%d rows x %d rols\n",wbuf.ws_row,wbuf.ws_col);
printf("%d wide x %d tal\n ",wbuf.ws_xpixel,wbuf.ws_ypixel);
rows=wbuf.ws_row;
}
initscr();
move(10,20);
addstr("hello,this is my first char graphics.\n");
move(rows,0);
refresh();
getch();
endwin;
refresh();
return 0;
}
* curses1.c
* 编译时最好带上 -lcurses 参数
*/
#include<stdio.h>
#include<sys/ioctl.h>
#include<curses.h>
int main(int ac,char *av[])
{
struct winsize wbuf;
int rows;
if(ioctl(0,TIOCGWINSZ,&wbuf)!=-1) //获取屏幕的大小方法
{
printf("%d rows x %d rols\n",wbuf.ws_row,wbuf.ws_col);
printf("%d wide x %d tal\n ",wbuf.ws_xpixel,wbuf.ws_ypixel);
rows=wbuf.ws_row;
}
initscr();
move(10,20);
addstr("hello,this is my first char graphics.\n");
move(rows,0);
refresh();
getch();
endwin;
refresh();
return 0;
}