歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> 關於getche()函數的問題

關於getche()函數的問題

日期:2017/2/27 12:09:16   编辑:Linux文化

>>> 此貼的回復 >> getchar

>>> 此貼的回復 >> 1. 你用 ncurses 提供的 getch() 與 getche() 這類由鍵盤取得一字元輸入,前提是當然已經進入 ncurses 的環境,要不然那些項目都無效...

ncures 使用,一般會是:

CODE:[Copy to clipboard]initscr(); getch(); /* 你要的 ? */ endwin(); 沒有 initscr 與 endwin 這類初始化與結束的話,裡面的 ncurses 相關的函數使用都無效。

2. 既然使用 ncurses library 的話,gcc 編譯時要傳入 -lncurses 連結 ncurses 相關程式庫。

CODE:[Copy to clipboard]gcc -o myprog -lncurses myprog.c 3. 若是你只是要能夠由 stdin 讀入一個字元,請使用標准 c library 提供的 getchar() 這類函數即可。

4. 若是你對於 ncurses 很有興趣,請閱讀: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/


Copyright © Linux教程網 All Rights Reserved