![]() |
VOOZH | about |
There are two methods in which input can be taken in a more secure way:
In this method, input content will be invisible. This can be implemented in two ways:
Program 1:
Below is the program where console mode is set to enable, echo input, and reset the console mode:
Output:
👁 ImageFor this getch() is used. This function takes a character input from user without buffer and doesn't wait for the user to press "return" key.
Program 2:
Below is the C++ program to demonstrate the use of getch() in conio.h:
Output:
👁 ImageDrawback: The user can't clear the response made earlier. When backspace is pressed, the input is returned.
Program 3:
Below is the C++ program to demonstrate the solution to the above drawback:
👁 ImageThe idea is to use the library <conio.h> here to hide password with asterisk(*). Below is the C++ program using conio.h to hide the password using *:
Program 4: