What is the use of getch() function? What's it's alternative in C++14? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the use of getch() function? What's it's alternative in C++14?

18th Sep 2016, 3:35 PM
Rajat Gupta
Rajat Gupta - avatar
2 Answers
+ 2
This function reads a single-byte character from the terminal associated with the current or specified window. I guess you're asking about the getch() we use before the last line of the program, right? When you run a .exe file you built, Your program will finish running and terminate itself after computing and displaying. But you won't be able to see the output. For that, just to stop there, so that you can see the output, we use getch(). Though it takes a character as input. you can use cin.get() as an alternative :)
18th Sep 2016, 4:22 PM
Mosiur Rahman
Mosiur Rahman - avatar
+ 1
thanks @mosiur
18th Sep 2016, 4:24 PM
Rajat Gupta
Rajat Gupta - avatar