/*This program asks the user to enter username and password. The problem is that I want that the program should
compare that is userpasswordl=akq2932002akq not only alphabet.*/
#include<iostream>
#include<string>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#define MAXLENGTH 25
using namespace std;
int msleep(unsigned long milisec)
{
struct timespec req={0};
time_t sec=(int)(milisec/1000);
milisec=milisec-(sec*1000);
req.tv_sec=sec;
req.tv_nsec=milisec*1000000L;
while(nanosleep(&req,&req)==-1)
continue;
return 1;
}
int main()
{
string usernamel;
cout<<"Please enter your Username: ";
getline(cin, usernamel);
msleep(2000);
std::cout<<"Please enter the password: ";
char userpasswordl[MAXLENGTH];
int i=0;
char a;
for(i=0;i<MAXLENGTH;)
{
a=getch();
if((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9'))
{
userpasswordl[i]=a;
cout<<"*";
++i;
}
if(a=='\b'&&i>=1)
{
cout<<"\b \b";
--i;
}
if(a=='\n')
{
userpasswordl[i]='\0';
break;
}
}
system("cls");
if(usernamel=="arslankq29")
{
int p=0;
for(i=0; userpasswordl[i]!='\0'; i++)
{
if(userpasswordl[i]!='a')//I want that the it should check that is userpasswordl=akq2932002akq not only alphabet a
{
p++;
break;
}
}
if(p==0)
{
msleep(2000);
cout<<"Welcome Master!!! Arslan K Q\n";
goto end;
}
else
{
msleep(2000);
cout<<"Error!!! Login is not correct. Please Re Run the Program.\n"<<'\n';
goto end;
}
}
else
{
msleep(2000);
cout<<"Error!!! Login is not correct. Please Re Run the Program.\n"<<'\n';
goto end;
}
end:
return 0;
}