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.
Printable View
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!