开发者

Can someone please explain line-by-line what this short, simple C program does and how I can run it?

开发者 https://www.devze.com 2023-02-12 19:25 出处:网络
#include<curses.h> //includes the curses library so it can be used in the function main() { //opening main method
#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?
   开发者_StackOverflow中文版 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

I am not sure about what this simple program is doing, and cannot seem to run it either ? Could someone please help me out here ?


I think you are looking for:

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号