3

当我们在网站上输入密码时,我们会看到 * 或 . 而不是字符。如何用 c++ 实现这一点。假设我试图通过标准输入输入密码,同时我将它存储在一个字符数组中并删除用户输入的字符并输出 *。我想删除字符是这里的技巧。但是我们如何在通过标准输出打印字符后删除它。

4

3 回答 3

2

_getch()使用(header )读取密钥<conio.h>,保存/处理它,然后打印 '*' 字符而不是它。<conio.h>但是,仅在 Windows afaik 上可用。

于 2012-10-17T07:48:34.367 回答
1

It depends upon the operating system and relevant libraries (the C++ standard does not define anything related to that).

On Linux, you might use ncurses or readline libraries (on the terminal). And if coding a GUI application, your toolkit (eg Qt) provides a relevant widget.

于 2012-10-17T07:41:41.147 回答
0

在控制台中的此页面C++ 密码中,您可以找到答案。他们使用conio.h库,但在这个页面的中间有一个更好的 Windows 解决方案。

于 2012-10-17T07:45:21.380 回答