Hi im a super begginer to C++
I wrote the code and it gives me 2errors.
Could you please try and fix it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
using namespace std;
int main()
{
string user;
string psw;
cout << "Username:" << endl; cin >> user;
cout << "Password:" << endl; cin >> psw;
if(user = Hordeon || psw = daboolic315){
cout << "Login accepted" << endl;
}
else{
cout << "Login denied, wrong username or password!" << endl;
}
return 0;
}
|
Also how to make password hidden while typing like
instead of daboolic315
this: **********
hm, problem was solved by this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string user = "";
string psw = "";
cout << "Username:" << endl;
cin >> user;
cout << "Password:" << endl;
cin >> psw;
if(user == "Hordeon" && psw == "yadayadayada"){
cout << "Login accepted" << endl;
}
else{
cout << "Login denied, wrong username or password!" << endl;
}
return 0;
}
|
Lol i had forgot to do == instead of =
and include <string>
:DD
But i still would like to know how to make password like this:
*****
instead of blablabla.
Last edited on
I don't think it is possible without using GUI which is much more complicated. But I am not completely sure.