yes, but there's not much actually enforcing it so be very very afraid.
As said, use the C++ string type instead. It's much nicer and less prone to giving you all kinds of nasty runtime errors.
yes, but there's not much actually enforcing it so be very very afraid.
As said, use the C++ string type instead. It's much nicer and less prone to giving you all kinds of nasty runtime errors.
If you decide to use the character array you would not be able to simply compare what the user typed with the string literal "David", you'd have to use the strcmp function.
Code:char password[20]; cout << "Password: "; cin >> password; if( password == "David" ) // Can't do this!You should include the <cstring> header if you want to do that.Code:char password[20]; cout << "Password: "; cin >> password; if( strcmp(password,"David") == 0 ) // Can do this!
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens