//password
#include <iostream>
#include<string.h>
#include<conio.h>
#include<stdio.h>
using namespace std;
struct password
{
char name[100], passwords[100], userid[100];
}real, login;
int main()
{
int i, id=1, pas=1, conf, len=0, opt;
char confirm[100] ,a[100];
menu:
cout<<"\t\t\n menu"
<<"\n\n 1. press 1 for sign in"
<<"\n 2. press 2 for login"
<<"\n 3. press 3 for exit";
cout<<"\n\n enter your choice";
cin>>opt;
gets(a);
switch(opt)
{
case 1:
cout<<"\n enter your name :";
gets(real.name);
cout<<"\n enter your userid :";
gets(real.userid);
retype:
cout<<"\n enter your password :";
for(i=0;;++i)
{
real.passwords[i]=getch();
cout<<"*";
if(real.passwords[i]==13)
break;
}
real.passwords[i]='\0';
cout<<"\n retype your password to confirm it :";
for(i=0;;++i)
{
confirm[i]=getch();
cout<<"*";
if(confirm[i]==13)
break;
}
confirm[i]='\0';
conf=strcmp(real.passwords,confirm);
if(conf==0)
{
cout<<"\npassword confirmed";
}
else
{
cout<<"\nretype your password";
goto retype;
}
break;
case 2:
log:
cout<<"\n\n login";
cout<<"\nenter your userid";
gets(login.userid);
cout<<"\nenter your password";
for(i=0;;++i)
{
login.passwords[i]=getch();
cout<<"*";
if(login.passwords[i]==13)
break;
}
login.passwords[i]='\0';
id=strcmp(real.userid,login.userid);
if(id==0)
{
pas=strcmp(real.passwords,login.passwords);
if(pas==0)
{
cout<<"\t\t\n welcome";
goto exit;
}
else
{
cout<<"your password is not correct";
goto log;
}
}
else
{
cout<<"your userid is incorrect";
goto log;
}
break;
case 3:
goto exit;
}
goto menu;
exit:
return 0;
}
0 comments:
Post a Comment