Fedora web server - Chapter 28 . Programming Environments and Interfaces 771

Chapter 28 . Programming Environments and Interfaces 771 putchar(c); } printf( ncharacters read: %dn , i + 1); return 0; } To compile this program, use the following command: $ gcc readkey.c -o readkey In the preceding code listing, readkey.c reads input from stdin until it encounters a newline (which is generated when you press the Enter key). Then it displays the text entered and the number of characters read (the count includes the newline) and exits. Here s how it works: $ ./readkey INPUT: There are three primary means of creating programs that interact with users at the command line There are three primary means of creating programs that interact with users at the command line characters read: 96 The text wraps oddly because of this book s formatting constraints. You can also feed readkey.c input from stdin using the cat command: $ cat /etc/passwd | ./readkey INPUT: root:x:0:0::/root:/bin/bash characters read: 28 In this case, you see only the first line of /etc/passwd because each line of the file ends with a newline. It should be clear that programmatically interacting with the command line is simple, but not terribly user-friendly or attractive. Creating Text-Mode User Interfaces with ncurses Screen manipulation libraries such as S-Lang and ncurses create more attractive programs, but, as you might expect, the tradeoff for a nicer looking interface is more complicated code. Ncurses, which stands for new curses, is free re-implementation of the classic curses UNIX screen-handling library. The term curses derives from the phrase cursor optimization, which succinctly describes what the curses library does: compute the fastest way to redraw a text-mode screen and place the cursor in the proper location.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Leave a Reply