C++ password

Status
Not open for further replies.

ploutarchos

Distinguished
Sep 15, 2008
10
0
18,560
ok..... iam working on password protection for my program but i have some little problems here...

here is my code:::::



[cpp]cout << "PASSWORD: ";
getline (cin,password);
if (password == "my pass")
{
menu();
cout << "Your Choice: ";
cin >> chose;

if (chose == '1')
{
menu2();
}
else

if (chose == '2')

menu3();
}
else
for (i=0; i<=5; i++)
{
cout<<"WRONG PASSWORD!!"<<endl;
cout<<"This Program Exiting in "<<sec--<<" seconds...";
Sleep(5000);
}

char cChar;
std::cin.get(cChar);
return 0;
} [/cpp]


I want after 5 seconds program exit.... and didn't write all the word just the time -1 ....
 
Can't remember exactly about the sleep procedure, but most programming languages take time in ms as parameter, so 5000 would be about 5 seconds (yes can vary a bit).

Can you describe in your own words how you want the soft to behave? And if you can indent the code it would also help.
 
Dude u can use delay function to do this
here's the following code for this instead of sleep:
//header file is <process.h> for exit(0) to close program

delay(5000);
exit(0);




 
Status
Not open for further replies.