Yes or No

Hi all forumers, I don't know how to start this, i'll try make it understandable via example..hoho..here it is, I would like to know how to make my application only recognize Yes or No, I mean like this, if my program say:

"Do you wish to continue? Yes or No?"

how can i make the application or console(dunno how to called that black screen) only receive Yes or No typing from the user, example, if user type other than Yes or No, nothings happen or the dialog may out like this:

"You need to type Yes or No only"

sorry I really don't know how to explain this things, I hope with the examples i given, It will give you guys hint on what I'm talking about ==' because i only want my console go to next stage by typing 'yes', right now, my program still execute even if i only type any word, or even space also ==' help me plis!! I'm still a newbie, thanks!!
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string>
#include <iostream>

bool yes_or_no()
{
    std::string yn ;

    while( std::cout << "Do you wish to continue? Yes or No? " &&
           std::getline( std::cin, yn ) && !( yn == "Yes" || yn == "No" ) )
                   std::cout << "You need to type Yes or No\n" ;

    return yn == "Yes" ;
}
Try inputting a string.then do an if else with "yes" and "no"
Thanks!
Topic archived. No new replies allowed.