getch

From RAD Studio
Jump to: navigation, search

Go Up to conio.h Index

Header File

conio.h

Category

Console I/O Routines

Prototype

int getch(void);

Description

Gets character from keyboard, does not echo to screen.

getch reads a single character directly from the keyboard, without echoing to the screen.

Note: Do not use this function in Win32 GUI applications.

Return Value

getch returns the character read from the keyboard.

Example

#include <conio.h>
#include <stdio.h>
int main(void)
{
  int c;
  int extended = 0;
  c = getch();
  if (!c)
    extended = getch();
  if (extended)
    printf("The character is extended\n");
  else
    printf("The character isn't extended\n");
  return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

+