Whoops, sorry, I forgot this was the C++ forum not the C forum. You can use "==" for comparing strings. Sorry about that misinformation.
The for() loop I suggested was for repeatedly reading password from the user. I think it might be better to go simpler with this instead of cramming a lot into the for loop.
Code:
for (int tries = 1; (tries < 5); tries++)
{
if (password == "pass")
{
cout << "acces allowed\n";
break; // exit the loop, password was correct so don't want to keep asking for it
}
else // not really necessary to have else, but maybe clearer
{
cout << "acces denied\n";
cin >> password
}
}
We were all noobs once