ExTrEmEDwarf Posted November 5, 2009 Posted November 5, 2009 Hello, recently i started reading e-books and watching online tutorials and today i made a password protection thing. But, i get compile errors and i dont know where are the typos. Im 100% sure that this code is correct but i cant find what wrong i do. Someone help me. This is the code: #include <windows.h> #include <iostream> #include <string> using namespace std; int main() { string password; cout << "Enter Password: "; cin >> password; if (password == "ExTrEmEDwarf") { system("CLS") cout << "You have just logged in!"<<-- end1; cout << end1; system("PAUSE"); } else { system("CLS"); cout << "Password is incorrect. Program will close in:" << end1; cout << end1; cout << "3" << end1; Sleep(1000); cout << "2" << end1; Sleep(1000); cout << "1" << end1; Sleep(1000); cout << "Closing" << end1; Sleep(1000); } } On compile it says this: 1>Main - 9 error(s), 0 warning(s) // Not ontopic answers will be deleted
Coolis® Posted November 5, 2009 Posted November 5, 2009 Iam not at home right now to test it anyway, did you add "string" ? if yes deleted this post... i can't find the problem :/
ExTrEmEDwarf Posted November 5, 2009 Author Posted November 5, 2009 Yeah i already added it #include <string> i wont delete your reply, u dont get post counts on offtopic anyway ::) Edit: I found another code for this, made very quick but i have error on this too: #include <iostream> #include <windows.h> using namespace std; int main () { string password; cout << "This program requires a password: "; getline (cin, password); if (password == "ExTrEmEDwarf") { cout << "\n Password is correct!"; } else { cout << "\n Password is wrong! \n Program is closing in 5 seconds!"; Sleep(5000); return 0; } system ("pause>null"); return 0; } 1>main - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Im using Visual C++ 2008 Express Edition.
MaestroLuke Posted November 5, 2009 Posted November 5, 2009 #include <iostream> #include <string> using namespace std; int main() { string pass,guess; pass = "Extreme"; cout << "Enter pass\n"; cin >> guess; if (pass == guess) cout << "success login\n"; else cout << "Failed to login\n"; return 0; } works perfect with mingw
ExTrEmEDwarf Posted November 5, 2009 Author Posted November 5, 2009 MaestroLuke helped meh via teamviewer. someone lock the topic :)
Recommended Posts