I'm trying to make a C++ program to read a password.
I made the program to cout *
, not the characters I write but my problem is when I want to delete character because they're wrong.
Example:
My constant password is 12345
If I enter 1235
the program will show ****
and I have to delete the last character. It's simple to remove it from the string but I want the last *
to disappear from the console just as it happens when you introduce you windows password.
Is it possible? If it is, can someone explain how?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Sipmly write the
'\b'
character to stdoutstd::cout<<"\b"
. If you are using cpp orprintf("\b")
for pure CThis statement surely works because after the cursor goes one character back and space given in above printf statement will overwrite the printed character on console output.
When I am writting to console using putch function ( from conio.h ) to simulate backspace key simple
or
not works I have to write:
or
Outputting the backspace character '\b' may help to move the output point back.
Specifically, outputting the string "\b \b" should blank out the last character output.
Try backspace \b or erase the whole line and print it again.