Checking Text

I would like to know how to check text input... like...

cout<<"Yes or No?\n";
cin>> //insert nonsense here

I figured I would use a char variable but I can't get it to check in an if statement later. Anyone care to help?
Use a std::string

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

int main()
{
   std::string input;

   std::cout << "Yes or No?" << std::endl;
   std::cin >> input;

   if(input == "Yes")
   {
      std::cout << "Yes!" << std::endl;
   }

   return 0;
}
Last edited on
Ahhhh! Okay! Thank you very much!
Topic archived. No new replies allowed.