主题:我需要高手指点下~~看下这个简单程序
帮忙注解下 我是新手 看不懂 最好是一个一个的分析 好让我学习
#include"conio.h"
#include"iostream.h"
#include"string.h"
int main()
{
char pd[100]=" ";
char pass[]="123456";//默认密码
int nowpos =0;
cout<<"input the password:"<<endl;
cout.flush();
char ch=_getch();
while(ch!=13)
{
if(ch==8)
{
if(nowpos>0)
{
nowpos--;
cout<<char(8)<<' '<<char(8);
cout.flush();
}
}
else
{
pd[nowpos]=ch;
cout<<"*";
cout.flush();
nowpos++;
}
ch=_getch();
}
if(strncmp(pd,pass,strlen(pass))==0&&nowpos==strlen(pass))
{
cout<<endl<<"rignt!"<<endl;
cout<<"1.XXXX,2.XXXXX choose one"<<endl;
L: cin>>ch;
if(ch==1)
{
//add your code here
}
else if(ch==2)
{
//add your code here
}
else
{
cout<<"please choose 1 or 2!"<<endl;
goto L;
}
}
else
{
cout<<endl<<"wrong! over"<<endl;
}
return 0;
}
#include"conio.h"
#include"iostream.h"
#include"string.h"
int main()
{
char pd[100]=" ";
char pass[]="123456";//默认密码
int nowpos =0;
cout<<"input the password:"<<endl;
cout.flush();
char ch=_getch();
while(ch!=13)
{
if(ch==8)
{
if(nowpos>0)
{
nowpos--;
cout<<char(8)<<' '<<char(8);
cout.flush();
}
}
else
{
pd[nowpos]=ch;
cout<<"*";
cout.flush();
nowpos++;
}
ch=_getch();
}
if(strncmp(pd,pass,strlen(pass))==0&&nowpos==strlen(pass))
{
cout<<endl<<"rignt!"<<endl;
cout<<"1.XXXX,2.XXXXX choose one"<<endl;
L: cin>>ch;
if(ch==1)
{
//add your code here
}
else if(ch==2)
{
//add your code here
}
else
{
cout<<"please choose 1 or 2!"<<endl;
goto L;
}
}
else
{
cout<<endl<<"wrong! over"<<endl;
}
return 0;
}