hey guys, this should be an easy one, i'm pretty noobish.
i'm trying to make a simple password-type thingy. all i need it to do is check a string input from the user, and execute code if the string matches what the program knows.
i'm sure you'll get what i'm trying to do with the code:
beginning with all the glory:
Code:#include "stdafx.h" #include <iostream> #include <conio.h> #include <string> using namespace std;i made another attempt at this same effort, convinced i could never get it right with what i was trying. so i did this:Code:int main() { string psd; cout << "enter password.\n"; getline( cin, psd ); if (psd == "joshua") cout << "it works!"; else cout << "you suck at life."; _getch() //this is just to save me from it closing out while i debug return 0; }
if you couldn't tell, my computer keeps insulting me. can anybody tell me what i'm doing wrong?Code:int main() { char psd[7]; cout << "password?"; cin >> psd; if (strcmp (psd, "joshua")) cout << "massive win."; else cout << "epic fail."; _getch(); return 0; }
i would appreciate it A LOT.




Reply With Quote
