how can i get my prog to accpet a text password
like:
cin>>passcode;
would accept a number i want sum text to be accepted
also what do i use i.e. int, char
how can i get my prog to accpet a text password
like:
cin>>passcode;
would accept a number i want sum text to be accepted
also what do i use i.e. int, char
cin.getline(passcode, 10);
plus you would define passcode as a char array, the size of which would depend on how long you wished the max length of the password you wanted. Remember arrays start at 0.
-PreludeCode:#include <iostream> #include <string> using std::cout; #define CORRECT_PASS "enter" int main ( void ) { std::string password; cout<<"Enter your password: "; std::getline ( std::cin, password ); if ( password == CORRECT_PASS ) cout<<"All is well\n"; else cout<<"Wrong password\n"; return 0; }
My best code is written with the delete key.
*gasp
comparing strings with ==. shame on you.
um you can...
"The most common form of insanity is a combination of disordered passions and disordered intellect with gradations and variations almost infinite."
>comparing strings with ==. shame on you.
The C++ string class has an overloaded operator == for comparing two strings. Perhaps you were in a C mindset when you read this.
-Prelude
My best code is written with the delete key.