>"no operator defined which takes a right-hand operand of type 'const char'
Post your code.
>when you type name you hit space and that cin will acknowledge the space being there?
cin's >> operator ignores whitespace unless you tell it to do otherwise. The best option for single line input is to use getline and parse the string once your program has it saved. The reason for reading an entire line is because the user may not know how to format their input such that your program understands. My reason for mentioning this is because dates are fomatted differently all over the world. It's easier just to read it as a string:
string name, date;
int age;
cout<<"Enter your name, age, and date of birth: ";
cin>> name >> age >> date;
Because users are rarely able to format input properly even when they do know how, dealing with an error is easier if you have the string in memory and can go over it again. Handling an error from the stream is not as simple because it is a read-once affair.
string record;
if ( getline ( cin, record ) ) {
if ( !is_valid ( record ) ) {
// Handle the error
}
else {
// Parse the record
}
}
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Offline 11,807 posts
since Sep 2004