Can I put quotes in "if statements?"

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
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";
  }
}
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?
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
Topic archived. No new replies allowed.