"getch is deprecated" Code Answer


microsoft decided to mark the name without underscore deprecated, because those names are reserved for the programmer to choose. implementation specific extensions should use names starting with an underscore in the global namespace if they want to adhere to the c or c++ standard - or they should mark themselves as a combined standard compliant environment, such as posix/ansi/iso c, where such a function then corresponds to one of those standards.

read this answer about getcwd() too, for an explanation by p. j. plauger, who knows stuff very well, of course.

if you are only interested to wait for some keys typed by the user, there really is no reason not to use getchar. but sometimes it's just more practical and convenient to the user to use _getch and friends. however, those are not specified by the c or c++ standard and will thus limit the portability of your program. keep that in mind.

By RJ Cole on July 28 2022
Only authorized users can answer the Search term. Please sign in first, or register a free account.