Passwords help
2 posters
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
Passwords help
I'm trying to include a password into my game, but it isn't working properly. I'm getting a bit confused about using strings :/
- Code:
cout << "Input a password:" << endl;
string p;
cin >> p;
if (p == "banana")
return 1;
else if (p == "define")
return 2;
else if (p == "pirate")
return 3;
else
{cout << " Invalid password" << endl;
return 0;}
ElliottH- Admin
- Posts : 16
Join date : 2012-02-23
Re: Passwords help
ahhh ignore this! i found the problem elsewhere..
ElliottH- Admin
- Posts : 16
Join date : 2012-02-23
Re: Passwords help
Just for future reference, comparing strings
- Code:
string cat = "cat";
if (cat.compare("dog") == 0) cout << "the strings are equal";
else cout << "the strings aren't equal";
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum