| coder213 (3) | |
|
Hello this is my Code for masking input and the only problem is when i hit backspace it does delete a character from the string but it doesn't delete a asteriks from the screen #include <iostream> #include <conio.h> #include <string> using namespace std; int main(){ char c; string password; while((c = _getch()) != 13) { if(c == 8) { password.erase(password.end() -1); cout.put(c); } if(c != 8) { password += c; if(c != 32) { cout.put('*'); } } if(c == 32) { cout.put(c); } } cout << endl << password << endl; system("pause"); } | |
|
Last edited on
|
|
| bobdabilder (76) | |||||
this might be ugly and a hack but I inserted a backspace, then space and backspace to clear it up.
instead of
| |||||
|
|
|||||
| coder213 (3) | |
| Thank you that worked great | |
|
|
|