getch() function
We use this function for storing a single character value in variable.
syntex
char ch;
ch=getch();
int main()
int main()
{
char ch;
printf("enter value of ch ");
ch =getch();
printf("\n value of ch is \t");
printf("%c",ch);
}
Input enter value of ch a
then don't need to hit enter
then don't need to hit enter
Output value of ch is a
This is simple implementation of getch() function. We can't enter more than one character using getch() function.
Points- we don't need to hit enter after input .
getche() function
We use this function for storing a single character value in variable.
syntex
char ch;
ch=getche();
int main()
{
char ch;
printf("enter value of ch ");
ch =getche();
printf("\n value of ch is \t");
printf("%c",ch);
}
Input enter value of ch (input always invisible)
then don't need to hit enter
then don't need to hit enter
Output value of ch is a
This is simple implementation of getche() function. We can't enter more than one character using getche() function.
Points
- we don't need to hit enter after input .
- In case of getche() function we can't see input values
No comments:
Post a Comment