Replace input with “ * ” C++

前端 未结 4 891
春和景丽
春和景丽 2020-12-22 06:21

i want the user to input a passwort. of course it\'s a secret passwort so nobody should see it. so i tried to replace the letters and numbers the user inputs, with \' * \'.

4条回答
  •  醉话见心
    2020-12-22 07:23

    Your question isn't as much about C++ as it is about how to interact with your terminal. The language is (deliberately) entirely agnostic of how input and output are handled, and everything that you're worried about is how the terminal behaves. As such, any answer will depend heavily on your platform and your terminal.

    In Linux, you will probably want to look into termios.h or ncurses.h. There's an old Posix function getpass() which does something similar to what you want, but it's deprecated.

    Unfortunately I have no idea how to approach terminal programming in Windows.

提交回复
热议问题