有人可以逐行解释这个简短的 C 程序的作用以及如何运行它吗?

标签 c ncurses

#include<curses.h> //includes the curses library so it can be used in the function
main()
{ //opening main method
    int i; //declare int i
    initscr(); //creates a terminal of a specific type?
    noecho(); // turn off echoing 
    for (i=0; I <5; i++) //loops from 0 to 4
        getch(); //takes one character from the keyboard, I think ?
    endwin();
} //restores the terminal

我不确定这个简单的程序在做什么,并且似乎也无法运行它? 有人可以帮我吗?

最佳答案

我认为您正在寻找:

initscr(); //This method initialize the current and standard screen
noecho(); // turn off echoing 
for (i=0; i <5; i++) //loops from 0 to 4
getch(); //YES you thinks right, it takes one character from the keyboard.
endwin();  //The endwin() function restores the terminal, by flushing any output to the  terminal and moving the cursor to the first column of the last line of the screen.

关于有人可以逐行解释这个简短的 C 程序的作用以及如何运行它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5059257/

相关文章:

c++ - cdecl 错误 : expected initializer before

perl - Perl 中的彩色终端输出

rust - 启动时Ncurses屏幕空白

c - 如何从流中获取两个连续的字符?

c - 索引到 char 数组以附加字符串

c++ - 混合 freopen 和 ncurses

c - 如何获取ncurses以输出星体平面unicode字符

c - C <curses.h> 中的段错误

c - 按位表达式作为 for 循环条件

c - 交换 C 中的 Printf 操作