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")
i cant givea proper reply as im on a phonebutfrom first glance... lines like
terminate= terminate + 3 can be shortened to terminate += 3
EDIT**
Hmm this might just be me but your program doesn't seem to make sense. You seem to jump from asking for the username to asking for the password without coming out of the first while loop. Personally I would use something like:
It appears "long" because you're sugarcoating the program with extras to make it look nice and complicated (a common mistake). A small, brief login program would be this (I mixed it up a bit):
#include <iostream>
usingnamespace std;
int main()
{
checkpoint:
string username;
string password;
string passwordcheck;
int selection;
int terminate;
cout<<"1. Create account\n2. Login\n";
cin>>selection;
switch (selection)
{
case 1:
cout<<"Enter account username: ";
getline(cin, username);
cout<<"Enter account password: ";
getline(cin, password);
cout<<"Please re-enter your password: ";
getline(cin, passwordcheck);
if (password == passwordcheck)
{
cout<<"Very well. Your account has been created.\n";
}
else {
cout<<"The two passwords don't match.\n";
goto checkpoint;
}
break;
case 2:
// code to log in; enter username and password and check comparison to previous
// login details, if any
}
etc. etc.