DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Simple input and output

getch

SYNOPSIS

   #include <ocurses.h>
   

int getch()

NOTES

EXAMPLE

   #include <ocurses.h>
   

main() { int ch;

initscr(); cbreak(); /* Explained later in the section "Input Options" */ addstr("Press any character: "); refresh(); ch = getch(); printw("\n\n\nThe character entered was a '%c'.\n", ch); refresh(); endwin(); }

The output from this program follows. The first refresh sends the addstr character string from stdscr to the terminal:

   Press any character:  []
   
   

Now assume that a w is typed at the keyboard. getch accepts the character and assigns it to ch. Finally, the second refresh is called and the screen appears as follows:

   Press any character:  w
   
   
   The character entered was a 'w'.
   
   
   $[]

For another example of getch, see ``The show program''.


Next topic: getstr
Previous topic: Input

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004