Monday, 17 September 2012

getch function

“The getch = get character. This function is used to get a single character input from the user” during execution of program. It also force to wait the output to stay on screen until any key pressed from keyboard.

Syntax:
  •      For value input: Variable name= getch();
  •      For screen holding at the end of program: getch();

Example:

     #include<stdio.h>
     #include<conio.h>
      void main ()
      {
      clrscr();
      char m;
      printf("Enter character:");
      m=getch();
      printf("The character you Entered=%c",m );
      getch();
      }

     Output:
     Enter character:
     The character u Entered=a