使用curses函数写的hello world 程序

 1 #include<stdio.h>
 2 #include<unistd.h>
 3 #include<stdlib.h>
 4 #include<curses.h>
 5 int main()
 6 {
 7         initscr();
 8         clear();
 9         move(5,15);
10         printw("%s","hello world");
11         move(10,15);
12         addstr("hello linux");
13         refresh();
14         sleep(2);
15         endwin();
16         exit(EXIT_SUCCESS);
17 }    

编译运行:

gcc curses.c -o curses -lncureses

./curses

所有的curses程序必须在开始使用curses函数之前对其进行初始化,并在结束使用后允许curses恢复原先设置。这两项工作是由initscr和endwin函数分别完成的。

posted @ 2014-11-14 14:09  尽子轨  阅读(236)  评论(0编辑  收藏  举报