Can I put quotes in "if statements?"

Apr 26, 2019 at 6:01pm
Hello everyone!
Right now, I was wondering if I could make a program where you have to enter a specific set of characters such as:
Open
And it would process in an "if statement."

If anyone could provide an answer, I would appreciate it.
Last edited on Apr 26, 2019 at 6:32pm
Apr 26, 2019 at 6:35pm
1
2
3
4
5
6
7
8
9
10
11
12
#include <string>
#include <iostream>

int main()
{
 std::string input;
  std::cin >> input;
  if (input == "Open")
  {
    std::cout << "Correct";
  }
}
Apr 26, 2019 at 6:39pm
I'm curious about the title of the question, did you just want to compare a string literal, or does your string literal contain a quotation mark?
Apr 26, 2019 at 6:48pm
The string does not contain a question mark. I was just taught to do that when I was writing.

Also, Thank you Repeater.
Last edited on Apr 26, 2019 at 6:48pm
Topic archived. No new replies allowed.