// Use * when the user enters the password. But if he fails. Delete with the delete key. On the screen, you can also see the effect of "one less after deletion"
/* Getch ():
Header file: conio. h
Function purpose: Read a character from the console, but it is not displayed on the screen.
Function prototype: int getch (void)
Returned value: read characters
For example:
Char ch; or Int ch;
Getch (); or CH = getch ();
Use getch (); wait for you to press any key, and then continue to execute the following statement;
Use CH = getch (); after you press any key, assign the ASCII code corresponding to the key character to CH, and then execute the following statement.
Easy to error: the header file is conio. h. Instead of stdio. h.
The specific effect of the escape character '/B' in C ++
Use a common program to demonstrate the difference between output results with this character and unused ones.
# Include <iostream. h>
Int main ()
{Cout <"ABC" <"VF"; // output abcvf}
# Include <iostream. h>
# Include <conio. h>
Int main ()
{Cout <"ABC" <'/B' <"VF"; // output abvf }*/
# Include <iostream>
# Include <conio. h>
Using namespace STD;
Int main ()
{
Int I = 0;
Char A [8];
Cout <"enter the password (the password cannot exceed 8 characters):" <Endl;
While (1)
{
A [I] = getch ();
If (A [I] = '/B') // important, E
{
Cout <'/B ';
Putch ('');
Cout <'/B ';
I --;
Continue;
}
If (A [I] = 13) // 13 is the Inter key.
{
A [I] = '/0 ';
Break;
}
Putch ('*');
I ++;
}
Cout <Endl;
Cout <;
System ("pause ");
Return 0;
}