I'm writing a new code that manages a client bank account but the problem is when he enters the password and it shows up as * and when I compare it to the actual password it turned up to be wrong. So I want a program that stores the password and checks if its correct.
Asked
Active
Viewed 57 times
-4
-
give me the login and password of some clients and I will do ^^ More seriously what about to give your code to allow us to say what is wrong ? – bruno Apr 27 '19 at 14:52
-
1Possible duplicate of [Enter Password in C](https://stackoverflow.com/questions/2634203/enter-password-in-c) – phuclv Apr 27 '19 at 14:58
-
4Your question is too broad. It really depends on the OS and there are a lot duplicates [C command-line password input](https://stackoverflow.com/q/1786532/995714), [Hide password input on terminal](https://stackoverflow.com/q/6856635/995714), [How to get a password with a CLI program?](https://stackoverflow.com/q/4050757/995714), [How does one display * when typing a password in a C/C++ command-line tool?](https://stackoverflow.com/q/13691249/995714), [Replace input with " * " C++](https://stackoverflow.com/q/7405312/995714) – phuclv Apr 27 '19 at 15:04
1 Answers
-2
Simplest solution. Have one default char that you print out (in this case star). Then print it out via for loop as per the length of client password.
char *clientPass = "asdf"
for(int g = 0; g < strlen(clientPass); g++)
print("*");
As per the information you have given in the question, this solution works

rassa45
- 3,482
- 1
- 29
- 43
-
2this doesn't show `*` as the user types one character. And it doesn't work if one deletes the characters – phuclv Apr 27 '19 at 15:05
-
ytpillai : are you ready to give here your bank account reference login and password, then some times after to edit your remark replacing letters with * ? ^^ – bruno Apr 27 '19 at 15:29
-
-
Are you saying in a gui or in the console? Console is not something your program can change in the same way across all possible input methods. You need to make your own gui via html or something and it'll work. – rassa45 Apr 28 '19 at 16:26