Making a login | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Making a login

Would this code work on windows? Is there a way to check of string values? I tried to run it on here and got an error about "Wulfy" not being declared. I dont want answers i want a good explantion please. Thank you guys :) #include <iostream> //#include <Windows.h> #include <string> using namespace std; int main() { string name; string pass; cout << "Login with provided Information\n" << "Username:"; //Sleep(5000) cout << "Password:\n"; if (name == Wulfy && pass == Wulfy) //Login name and Password { cout << "Accepted"; } else { cout << "Denied"; //Sleep(10000); //return 0; // this code above here is for if it was on a windows computer } }

3rd Mar 2017, 7:17 PM
Chandler
3 Answers
+ 2
Its cin
3rd Mar 2017, 7:38 PM
Chandler
+ 2
#include <iostream> //#include <Windows.h> #include <string> using namespace std; int main() { string name; string pass; string Wulfy = "Wulfy"; cout << "Login with provided Information\n" << "Username: \n"; cin >> name; //Sleep(5000) cout << "Password: \n"; cin >> pass; if (name == Wulfy && pass == Wulfy) //Login name and Password { cout << "Accepted"; } else { cout << "Denied"; //Sleep(10000); //return 0; // this code above here is for if it was on a windows computer } }
3rd Mar 2017, 7:40 PM
Chandler
0
Thanks man, i fixed up the code a bit
3rd Mar 2017, 7:34 PM
Chandler