《Beginning Linux programming》Third Editon (linux 程序设计 第三版)的第六章

ubuntu 安装ncurses

首先学习安装curese 或者 ncurses 函数库,ncurses是字符终端下屏幕控制的基本库.

可能很多新开发的程序都不使用了,所以buntu9.0.4自己没有带这个库,一次还要自己apt-get安装。当然需要如果要编译一些老程序,也还是会经常遇得到。
执行命令就可以了。

sudo apt-get install libncurses5-dev

在编译的时候在编译选项中添加一项: -lncurses

程序的历程是这样的:

/*screen1.c*/
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>

int main()
{
initscr();

move(5,15);
printw("%s","hello world");
refresh();
sleep(2);

endwin();
exit(EXIT_SUCCESS);
}



编译选项是:
huzia@huzia-laptop:~/ch06$ gcc screen1.c -o screen1 -lncurses

你可能感兴趣的:(programming)