如何用“*”字符替换输入字符?

How can I replace the input character with the "*" character?

如何将输入的字符替换为“*”字符?一切都应该在输入时发生(就像在网站上注册时输入密码一样)。 谢谢解答!!!

最简单的方法,我觉得是这样的:

#include <iostream>
#include <string>
#include <conio.h>

int main()
{
    std::string str;
    char ch;
    std::cout << "enter the text: ";
    while((ch = _getch()) != 13) //enter type
    {
        str+= ch;
        std::cout << '*';
    }
}