I write a little program, just want to test getch() function.
When you enter password, they dont display in monitor,
instead of "*". It 's running OK.
But some statements look very stupid,
please give some improvement!
thanks.
PHP Code:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
void main()
{
char m[3]={'t','o','y'}; //to save original password.
char n[3]={'0','0','0'}; //initialize your entering password.
cout<<"Please enter 3 bit password: "<<flush;
n[0]=getch(); //enter word ,but no display it
cout<<"*"<<flush; //when enter word, display “*”
n[1]=getch();
cout<<"*"<<flush;
n[2]=getch();
cout<<"*"<<flush;
if(m[0]==n[0]&&m[1]==n[1]&&m[2]==n[2]) //stupid code!
{
cout<<"password correct,welcome!"<<endl;
}
else
{
cout<<"error."<<endl;
}
system("pause"); //pause running window.
return;
}