Getche function >> conio.h Header file >> Library Functions in C Programming

What it does :
  1. Getche accepts character from console
  2. Character accepted  echoes to the screen [ displayed on screen ]
  3. Header File : conio.h
int getche(void);

Live Examples :

#include"stdio.h"
#include"conio.h"

void main(void)
{
char ch;
printf("Input a character:");
ch = getche();
printf("nYou input a '%c'n", ch);
}


Output :
You input a 'x'

Ways of Using getche function :

Way 1 : To Loop back

void main()
{
char ch;
do
{
printf("You are in Do while Loop ");

printf("Do you want to continue , Y to continue , N to quit ");

ch = getche();

}while(ch!='N');
}

Bookmark & Share