Creating program envolving password

Hello everyone! im new to c++. Im trying to do a program in which the user have to enter a password if he wants to enter something, for example, a folder in desktop. If he puts the correct password, he enters in. But if he puts the wrong password, it appears saying that he has only 2 tries left and after he reaches this limit, the program closes. I know this shall be quite easy for you, but i just cant do it... help me, show me your source codes, id like to see them.. :D
hmmm.

try
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
string password="Pineapple";
string temp;
int rounds=3;
while(rounds>0)
{
cout<<"Please enter the password!"<<endl;
cin>>temp;
if(temp!=password)
{
rounds--;
}
else
{
system("\"%%PATH%%\"");
return 0;
}
}

return 0;
}


And replace %%PATH%% with the path to the file.

You could write a program that does that same exact thing in 10 bytes, if you use machine code. (´ º Í!ÃH$)
Last edited on
thank you, but i still have a problem. Ive got the errors: [Warning] unknown escape sequence '\A' and [Warning] unknown escape sequence '\A'.
it says that it is in line 21 (system("\"%%PATH%%\"");). I replaced %%PATH%% and put: system("\"E:\Arquivo\zydeoN\""); is it alright?


forget it, i figured it out xD. Instead of
system("\"E:\Arquivo\zydeoN\"") i had to put: system("\"E:\\Arquivo\\zydeoN\"")
, with the \\. Now its working. think im getting more and more excited with this stuff of programming =D
Last edited on
Topic archived. No new replies allowed.