expected While before numeric value
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 29
|
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
int i;
string password;
cout << "Enter the password" << endl;
cin >> password;
do
{
BACK: { }
int var = 0;
if (password == "password")
{
cout << "Access Granted!";
}
else
{
cout << "Access Denyed!";
}
if (i==0)
{goto BACK;}
}
return 0;
}
|
I get the errors
cpp|28|error: expected `while' before numeric constant|
cpp|28|error: expected `(' before numeric constant|
cpp|28|error: expected `)' before ';' token|
What am I doing wrong here?
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 29
|
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
int i;
string password;
cout << "Enter the password" << endl;
cin >> password;
do
{
BACK: { }
int var = 0;
if (password == "password")
{
cout << "Access Granted!";
}
else
{
cout << "Access Denyed!";
}
if (i==0)
{goto BACK;}
} while (/*your test value*/)
return 0;
}
|
Id a do...while loop is what you were trying to do, than that's the solution. If not, tell me what you are trying to do
I'm trying to loop the program for when the wrong password is entered it makes you re-input another password until you correctly input the password
Topic archived. No new replies allowed.