A more effeicent way to get input from the user

Is there a more effective way of getting input from the user other than

cout << "Do you want to buy a sword?" << endl;
string sword;
cin >> sword;
if (sword=="yes" or "Yes"){
cout << "Okay"
else{cout << haha <<endl; }}

this causes issues if you mispell it when playing
thanks for your time
Input validation is fun stuff, and a huge part of programs that have any user interaction. C++ standard input functions have various failbits that will be flagged if input went awry. Should look into this. The documentation on this site has it explained pretty well. It'll catch a good portion of bad input, the rest of the work is up to you
Topic archived. No new replies allowed.