answersLogoWhite

0

Both getch() and getche() are used to read single character there is very little difference

-getch() doesn't display output to screen if used without lvalue

-getche() display output to screen even if used without lvalue

following example will clear this.....

1.

main()

{

getch();

}

2.

main()

{

getche();

}

after running above programs...............

when you press any key, you'll exit from output screen

verify the output by pressing alt+F5

1. will not show anything

2.will show the key you were pressed......

hope you get it.............

__________________________________________________________________

getch() - get character from screen without echo and compiler didn't wait for another key.

getche() - get character from screen and compiler didn't wait for another key

getchar() - get character from screen and compiler wait for another key and moreover it returns a integer value i.e. the ASCII(American Standard Code for Information exchange) which we can use where ever we want.for example:- mostly in encryption.

In this the major concept is of echoing and it is nothing but when we enter anything through keyboard and if it is coming back on the screen (even if to show that what we are entering ) that's called echoing.

and this is what makes difference in getch() and getche()

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
BeauBeau
You're doing better than you think!
Chat with Beau
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
More answers

Getchar() will accept a character from keyboard displays immediately while typing and need Enter key to pressed for proceeding.

Getch() Normally we will use it at the end of the main(). It just accepts a key stroke and never displays it and proceeds further.

Getche() will accept a character from keyboard display it immediately does not wait for Enter key to pressed for proceeding.

__________________________________________________________________

getch() - get character from screen without echo and compiler didn't wait for another key.

getche() - get character from screen and compiler didn't wait for another key

getchar() - get character from screen and compiler wait for another key.

__________________________________________________________________

User Avatar

Wiki User

14y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is difference between getchar and getch?
Write your answer...
Submit
Still have questions?
magnify glass
imp