複製鏈接
請複製以下鏈接發送給好友

initscr

鎖定
initscr,是計算機編程的函數語言之一。
外文名
initscr
函數原型
WINDOW * initscr(void);
頭文件
#include
特    點
在一個程序中只能調用一次

initscr頭文件

#include<curses.h>

initscr函數原型

WINDOW * initscr(void);

initscr函數説明

initscr函數在一個程序中只能調用一次。如果成功,它返回一個指向stdscr結構的 指針;如果失敗,它就輸出一條診斷錯誤信息並使程序退出。

initscr範例

[root@localhost chapter06]# cat screen1.c
#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);
    printf("%s", "Hello World");
    refresh();
    sleep(2);
    endwin();
    exit(EXIT_SUCCESS);
}
[root@localhost chapter06]# gcc -o screen1 screen1.c -lcurses
[root@localhost chapter06]# ./screen1