i would really love to know if there's any other way to get the functionality of getch()(i.e without using getch()) in the above mentioned cases.
The problem with unbuffered input is that it becomes the responsibility of the programmer to handle the buffering. Do you allow the user to make a typing mistake? Then handle the backspace. Then you can't have immediate response because you need an "enter" for a 'final' answer. Then you're back where you started with the standard way.
The reason it may 'work well' might be because other issues have been overlooked. It seems a more reasonable approach is to use standard functions that have already taken such issues into account and move forward. Yet this opinion is revisited thousands of times every year by programmers. Their first goal seems to be clearing the screen. Frankly, if the command shell commands behaved this way, I'd be pretty annoyed: execute two 'dir' commands consecutively, and the second throws away the result of the first -- annoying.
Ah well, it seems new programmers always must go full circle. I do try to get them to go the right way first, otherwise it seems to be a much longer journey.
That said, any nonstandard function has the implied disclaimer, "use at your own risk"! :p
Reputation Points: 2780
Solved Threads: 312
long time no c
Offline 4,790 posts
since Apr 2004