| | |
LOGIN
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2009
Posts: 16
Reputation:
Solved Threads: 0
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..
C++ Syntax (Toggle Plain Text)
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; }
Last edited by Narue; Apr 10th, 2009 at 11:42 am. Reason: fixed code tags
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
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" ...
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" ...
Last edited by tux4life; Apr 10th, 2009 at 12:01 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
![]() |
Similar Threads
- Windows XP slow login (Windows NT / 2000 / XP)
- network login problem (Windows NT / 2000 / XP)
- can't get past xp login (Windows NT / 2000 / XP)
- XP anf Novell Client Dual Login (Novell)
- Cannot Login to Mac (OS X)
- login screen config (Window and Desktop Managers)
Other Threads in the C++ Forum
- Previous Thread: get rid of the punctuations function
- Next Thread: Databasing problem
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






