input validation

Hello knowledgeable peoples,

char name[4]
cout<<"Enter Bob or Ted";
cin>>name;

How do I verify that input was Bob or Ted and not fred or 69&? Is it possible with char or do I have to use strings and if so how?

Thank you.
Avoid char arrays for stream input at all costs. Use only std::string.

Then you just need to check:
 
if ("Bob" == name or "Ted" == name) { OK... } else { Bad... }
Topic archived. No new replies allowed.