Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

#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

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..