Alternative function in iostream.h for getch() of conio.h?

后端 未结 10 1034
无人共我
无人共我 2020-11-30 09:55

I\'m trying to hold the screen on my output using the header file , but I don\'t know any equivalent function to the getch() &

10条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 10:25

    The platform-specific function getch() from conio.h has two special features:

    • No echoing of characters.
    • Unbuffered reading of characters.

    The echoing is done by the terminal outside of the C/C++ environment. It can only be controlled by manipulating the terminal. Also, it is nearly impossible to get unbuffered I/O with the iostream.h header.

    Therefore it is not possible to get anywhere near getch() using iostream.h alone.

    (There are plenty of getch()implementations around, e.g. using termios.h to disable echoing.)

提交回复
热议问题