该程序测试时是向屏幕写入字符串,比较简单

编译时如果说函数找不到请带上 -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;
}

 

相关文章:

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