頭檔案
#include<curses.h>
函式原型
WINDOW * initscr(void);
函式說明
initscr函式在一個程式中只能調用一次。如果成功,它返回一個指向stdscr結構的 指針;如果失敗,它就輸出一條診斷錯誤信息並使程式退出。
範例
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
int main() {
initscr();
/* We move the cursor to the point (5,15) on the logical screen,
print "Hello World" and refresh the actual screen.
Lastly, we use the call sleep(2) to suspend the program for two seconds,
so we can see the output before the program ends. */
move(5, 15);
printw("%s", "Hello World");
refresh();
sleep(2);
endwin();
exit(EXIT_SUCCESS);
}
[root@localhost chapter06]# gcc -o screen1 screen1.c -lcurses