please i was wondering if anyone could help me with my code, i feel its kinda too long and a good program should be as brief as possible... please would be very grateful. appreciated, cheers..

int _tmain(int argc, _TCHAR* argv[])			
{
string Username;
string Password;
int terminator = 0, terminate = 0;				
char encrypt;

while (terminate < 2)							
{
cout << "Enter Username: ";							
getline(std::cin, Username);					
if (Username == "Raymond") 
	
{
	terminate = terminate + 3;					 

	while (terminator < 2)						{
cout << "\nEnter Password: ";							
encrypt = _getch();


   while(encrypt != 13)

   { 
	   Password.push_back(encrypt);				
	  cout << '*';
      encrypt = _getch();  
   }

if (Password == "123456")						
{
	cout <<"\n\n\t\t******************************";
	cout << "\n\t\t*			     *";
	cout << "\n\t\t*			     *";
	cout << "\n\t\t*	Welcome Raymond	     * ";			
	cout << "\n\t\t*			     *";
	cout <<"\n\t\t******************************"<< endl<<endl ;
terminator = terminator + 3;					
}

else								
{
cout << "\nInvalid password. Please enter valid password." << std::endl;
cout << "\a\n";
terminator = terminator + 1;				
}
}			

} else {							
cout << "Invalid username. Please enter valid username." << std::endl;
cout << "\a\n";
terminate = terminate + 1;
}
} 

	
	return 0;				

}

Why are you hard coding the username and password in the code, if you want to improve your login system (make it more universal) you could make an account database where the username and password are stored in ...

Edit:: You could also use a bool called 'terminate', and you let your while run like this while(!terminate) ...
Edit:: It's also a bad security practice when you're notifying the user when a username doesn't exist, it would be better if you ask the user to enter a username and a password, and when one of these is wrong you simply notify the user with "Wrong username or password" ...

It would also be nice if it worked. Did you test it fully? Try entering an incorrect password followed by the correct password.

Also, terminate and terminator are confusing names. How about triesUsername and triesPassword ?

It will better for the program if the username and password is defined by the user itself..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.